diff options
author | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 21:52:16 +0000 |
---|---|---|
committer | dmaclach@chromium.org <dmaclach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-19 21:52:16 +0000 |
commit | d4e186524ef4db7f227c57dd61ef727c5eaac623 (patch) | |
tree | 7bf4bc7a25f60c3de9f03f917907fdb151735a81 /chrome | |
parent | 2d9c6094d497fac4714ff79205de870c3b6ccaa1 (diff) | |
download | chromium_src-d4e186524ef4db7f227c57dd61ef727c5eaac623.zip chromium_src-d4e186524ef4db7f227c57dd61ef727c5eaac623.tar.gz chromium_src-d4e186524ef4db7f227c57dd61ef727c5eaac623.tar.bz2 |
Moved a whole pile of unittests over to CocoaTest.
AboutIPC.xib - Connected up controller to its window and the window delegate to the controller.
BUG=26484, 26484
TEST=See repro steps in bugs.
Review URL: http://codereview.chromium.org/402066
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32551 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
48 files changed, 537 insertions, 1249 deletions
diff --git a/chrome/app/nibs/AboutIPC.xib b/chrome/app/nibs/AboutIPC.xib index b943f80..2c4d1dc 100644 --- a/chrome/app/nibs/AboutIPC.xib +++ b/chrome/app/nibs/AboutIPC.xib @@ -1,18 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> -<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10"> +<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03"> <data> <int key="IBDocument.SystemTarget">1050</int> - <string key="IBDocument.SystemVersion">10A432</string> - <string key="IBDocument.InterfaceBuilderVersion">732</string> - <string key="IBDocument.AppKitVersion">1038</string> - <string key="IBDocument.HIToolboxVersion">437.00</string> - <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> - <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string> - <string key="NS.object.0">732</string> - </object> + <string key="IBDocument.SystemVersion">9L31a</string> + <string key="IBDocument.InterfaceBuilderVersion">677</string> + <string key="IBDocument.AppKitVersion">949.54</string> + <string key="IBDocument.HIToolboxVersion">353.00</string> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <bool key="EncodedWithXMLCoder">YES</bool> - <integer value="1"/> </object> <object class="NSArray" key="IBDocument.PluginDependencies"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -20,7 +15,7 @@ </object> <object class="NSMutableDictionary" key="IBDocument.Metadata"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys" id="0"> + <object class="NSArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> </object> <object class="NSMutableArray" key="dict.values"> @@ -46,10 +41,10 @@ <string key="NSWindowTitle">about:ipc</string> <string key="NSWindowClass">NSWindow</string> <nil key="NSViewClass"/> - <string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string> + <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{946, 321}</string> <object class="NSView" key="NSWindowView" id="1006"> - <reference key="NSNextResponder"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -65,7 +60,7 @@ <string key="NSContents">Start</string> <object class="NSFont" key="NSSupport" id="839892825"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">13</double> + <double key="NSSize">1.300000e+01</double> <int key="NSfFlags">1044</int> </object> <reference key="NSControlView" ref="1024951726"/> @@ -123,28 +118,28 @@ <object class="_NSCornerView" key="NSCornerView" id="567849339"> <reference key="NSNextResponder" ref="98924657"/> <int key="NSvFlags">-2147483392</int> - <string key="NSFrame">{{890, 0}, {16, 17}}</string> + <string key="NSFrame">{{-26, 0}, {16, 17}}</string> <reference key="NSSuperview" ref="98924657"/> </object> <object class="NSMutableArray" key="NSTableColumns"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSTableColumn" id="238645834"> <string key="NSIdentifier">0</string> - <double key="NSWidth">94</double> - <double key="NSMinWidth">40</double> - <double key="NSMaxWidth">1000</double> + <double key="NSWidth">9.400000e+01</double> + <double key="NSMinWidth">4.000000e+01</double> + <double key="NSMaxWidth">1.000000e+03</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> <string key="NSContents">Time</string> <object class="NSFont" key="NSSupport" id="26"> <string key="NSName">LucidaGrande</string> - <double key="NSSize">11</double> + <double key="NSSize">1.100000e+01</double> <int key="NSfFlags">3100</int> </object> <object class="NSColor" key="NSBackgroundColor" id="703945268"> <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes> + <bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes> </object> <object class="NSColor" key="NSTextColor" id="272087706"> <int key="NSColorSpace">6</int> @@ -168,7 +163,7 @@ <string key="NSColorName">controlBackgroundColor</string> <object class="NSColor" key="NSColor" id="430184259"> <int key="NSColorSpace">3</int> - <bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes> + <bytes key="NSWhite">MC42NjY2NjY2OQA</bytes> </object> </object> <object class="NSColor" key="NSTextColor" id="212665692"> @@ -184,9 +179,9 @@ </object> <object class="NSTableColumn" id="277179295"> <string key="NSIdentifier">1</string> - <double key="NSWidth">108</double> - <double key="NSMinWidth">40</double> - <double key="NSMaxWidth">1000</double> + <double key="NSWidth">1.080000e+02</double> + <double key="NSMinWidth">4.000000e+01</double> + <double key="NSMaxWidth">1.000000e+03</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> @@ -210,9 +205,9 @@ </object> <object class="NSTableColumn" id="1025181063"> <string key="NSIdentifier">2</string> - <double key="NSWidth">195</double> - <double key="NSMinWidth">10</double> - <double key="NSMaxWidth">3.4028234663852886e+38</double> + <double key="NSWidth">1.950000e+02</double> + <double key="NSMinWidth">1.000000e+01</double> + <double key="NSMaxWidth">3.402823e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> @@ -244,9 +239,9 @@ </object> <object class="NSTableColumn" id="983835171"> <string key="NSIdentifier">3</string> - <double key="NSWidth">49</double> - <double key="NSMinWidth">10</double> - <double key="NSMaxWidth">3.4028234663852886e+38</double> + <double key="NSWidth">4.900000e+01</double> + <double key="NSMinWidth">1.000000e+01</double> + <double key="NSMaxWidth">3.402823e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> @@ -270,9 +265,9 @@ </object> <object class="NSTableColumn" id="756023669"> <string key="NSIdentifier">4</string> - <double key="NSWidth">81</double> - <double key="NSMinWidth">10</double> - <double key="NSMaxWidth">3.4028234663852886e+38</double> + <double key="NSWidth">8.100000e+01</double> + <double key="NSMinWidth">1.000000e+01</double> + <double key="NSMaxWidth">3.402823e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> @@ -296,9 +291,9 @@ </object> <object class="NSTableColumn" id="325673043"> <string key="NSIdentifier">5</string> - <double key="NSWidth">75</double> - <double key="NSMinWidth">10</double> - <double key="NSMaxWidth">3.4028234663852886e+38</double> + <double key="NSWidth">7.500000e+01</double> + <double key="NSMinWidth">1.000000e+01</double> + <double key="NSMaxWidth">3.402823e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> @@ -322,9 +317,9 @@ </object> <object class="NSTableColumn" id="933394012"> <string key="NSIdentifier">6</string> - <double key="NSWidth">281</double> - <double key="NSMinWidth">10</double> - <double key="NSMaxWidth">3.4028234663852886e+38</double> + <double key="NSWidth">2.810000e+02</double> + <double key="NSMinWidth">1.000000e+01</double> + <double key="NSMaxWidth">3.402823e+38</double> <object class="NSTableHeaderCell" key="NSHeaderCell"> <int key="NSCellFlags">75628096</int> <int key="NSCellFlags2">2048</int> @@ -347,8 +342,8 @@ <reference key="NSTableView" ref="493623503"/> </object> </object> - <double key="NSIntercellSpacingWidth">3</double> - <double key="NSIntercellSpacingHeight">2</double> + <double key="NSIntercellSpacingWidth">3.000000e+00</double> + <double key="NSIntercellSpacingHeight">2.000000e+00</double> <reference key="NSBackgroundColor" ref="193056335"/> <object class="NSColor" key="NSGridColor"> <int key="NSColorSpace">6</int> @@ -359,20 +354,16 @@ <bytes key="NSWhite">MC41AA</bytes> </object> </object> - <double key="NSRowHeight">17</double> + <double key="NSRowHeight">1.700000e+01</double> <int key="NSTvFlags">-566231040</int> - <reference key="NSDelegate"/> - <reference key="NSDataSource"/> <int key="NSColumnAutoresizingStyle">4</int> <int key="NSDraggingSourceMaskForLocal">15</int> <int key="NSDraggingSourceMaskForNonLocal">0</int> <bool key="NSAllowsTypeSelect">YES</bool> - <int key="NSTableViewDraggingDestinationStyle">0</int> </object> </object> <string key="NSFrame">{{1, 17}, {904, 172}}</string> <reference key="NSSuperview" ref="98924657"/> - <reference key="NSNextKeyView" ref="493623503"/> <reference key="NSDocView" ref="493623503"/> <reference key="NSBGColor" ref="150175725"/> <int key="NScvFlags">4</int> @@ -384,7 +375,7 @@ <reference key="NSSuperview" ref="98924657"/> <reference key="NSTarget" ref="98924657"/> <string key="NSAction">_doScroller:</string> - <double key="NSPercent">0.91279069767441856</double> + <double key="NSPercent">9.127907e-01</double> </object> <object class="NSScroller" id="272438547"> <reference key="NSNextResponder" ref="98924657"/> @@ -394,7 +385,7 @@ <int key="NSsFlags">1</int> <reference key="NSTarget" ref="98924657"/> <string key="NSAction">_doScroller:</string> - <double key="NSPercent">0.99889502762430937</double> + <double key="NSPercent">9.988950e-01</double> </object> <object class="NSClipView" id="855547419"> <reference key="NSNextResponder" ref="98924657"/> @@ -405,7 +396,6 @@ </object> <string key="NSFrame">{{1, 0}, {904, 17}}</string> <reference key="NSSuperview" ref="98924657"/> - <reference key="NSNextKeyView" ref="1005294920"/> <reference key="NSDocView" ref="1005294920"/> <reference key="NSBGColor" ref="150175725"/> <int key="NScvFlags">4</int> @@ -414,7 +404,6 @@ </object> <string key="NSFrame">{{20, 111}, {906, 190}}</string> <reference key="NSSuperview" ref="1006"/> - <reference key="NSNextKeyView" ref="521807537"/> <int key="NSsFlags">562</int> <reference key="NSVScroller" ref="95866814"/> <reference key="NSHScroller" ref="272438547"/> @@ -456,7 +445,7 @@ <string key="NSContents">Events:</string> <object class="NSFont" key="NSSupport"> <string key="NSName">LucidaGrande-Bold</string> - <double key="NSSize">13</double> + <double key="NSSize">1.300000e+01</double> <int key="NSfFlags">16</int> </object> <reference key="NSControlView" ref="478845374"/> @@ -854,11 +843,10 @@ </object> </object> <string key="NSFrameSize">{946, 321}</string> - <reference key="NSSuperview"/> </object> <string key="NSScreenRect">{{0, 0}, {2560, 1578}}</string> <string key="NSMinSize">{946, 343}</string> - <string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string> + <string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string> </object> <object class="NSArrayController" id="553651912"> <object class="NSMutableArray" key="NSDeclaredKeys"> @@ -1254,11 +1242,19 @@ </object> <object class="IBConnectionRecord"> <object class="IBOutletConnection" key="connection"> + <string key="label">window</string> + <reference key="source" ref="1001"/> + <reference key="destination" ref="1005"/> + </object> + <int key="connectionID">209</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> <string key="label">delegate</string> <reference key="source" ref="1005"/> <reference key="destination" ref="1001"/> </object> - <int key="connectionID">208</int> + <int key="connectionID">210</int> </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> @@ -1266,26 +1262,28 @@ <bool key="EncodedWithXMLCoder">YES</bool> <object class="IBObjectRecord"> <int key="objectID">0</int> - <reference key="object" ref="0"/> + <object class="NSArray" key="object" id="875074184"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> <reference key="children" ref="1000"/> <nil key="parent"/> </object> <object class="IBObjectRecord"> <int key="objectID">-2</int> <reference key="object" ref="1001"/> - <reference key="parent" ref="0"/> - <string key="objectName">File's Owner</string> + <reference key="parent" ref="875074184"/> + <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string> </object> <object class="IBObjectRecord"> <int key="objectID">-1</int> <reference key="object" ref="1003"/> - <reference key="parent" ref="0"/> + <reference key="parent" ref="875074184"/> <string key="objectName">First Responder</string> </object> <object class="IBObjectRecord"> <int key="objectID">-3</int> <reference key="object" ref="1004"/> - <reference key="parent" ref="0"/> + <reference key="parent" ref="875074184"/> <string key="objectName">Application</string> </object> <object class="IBObjectRecord"> @@ -1295,7 +1293,7 @@ <bool key="EncodedWithXMLCoder">YES</bool> <reference ref="1006"/> </object> - <reference key="parent" ref="0"/> + <reference key="parent" ref="875074184"/> </object> <object class="IBObjectRecord"> <int key="objectID">2</int> @@ -1500,7 +1498,7 @@ <object class="IBObjectRecord"> <int key="objectID">37</int> <reference key="object" ref="553651912"/> - <reference key="parent" ref="0"/> + <reference key="parent" ref="875074184"/> <string key="objectName">Log Array Controller</string> </object> <object class="IBObjectRecord"> @@ -1801,7 +1799,7 @@ </object> <object class="NSMutableDictionary" key="flattenedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> + <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>-1.IBPluginDependency</string> <string>-2.IBPluginDependency</string> @@ -1877,9 +1875,9 @@ <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{42, 1144}, {946, 321}}</string> + <string>{{42, 535}, {946, 321}}</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string> - <string>{{42, 1144}, {946, 321}}</string> + <string>{{42, 535}, {946, 321}}</string> <integer value="1"/> <string>{196, 240}</string> <string>{{357, 418}, {480, 270}}</string> @@ -1946,7 +1944,9 @@ </object> <object class="NSMutableDictionary" key="unlocalizedProperties"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference key="dict.sortedKeys" ref="0"/> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> @@ -1954,13 +1954,15 @@ <nil key="activeLocalization"/> <object class="NSMutableDictionary" key="localizations"> <bool key="EncodedWithXMLCoder">YES</bool> - <reference key="dict.sortedKeys" ref="0"/> + <object class="NSArray" key="dict.sortedKeys"> + <bool key="EncodedWithXMLCoder">YES</bool> + </object> <object class="NSMutableArray" key="dict.values"> <bool key="EncodedWithXMLCoder">YES</bool> </object> </object> <nil key="sourceID"/> - <int key="maxID">208</int> + <int key="maxID">210</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -1970,7 +1972,7 @@ <string key="superclassName">NSWindowController</string> <object class="NSMutableDictionary" key="actions"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> + <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>clear:</string> <string>startStop:</string> @@ -1983,7 +1985,7 @@ </object> <object class="NSMutableDictionary" key="outlets"> <bool key="EncodedWithXMLCoder">YES</bool> - <object class="NSArray" key="dict.sortedKeys"> + <object class="NSMutableArray" key="dict.sortedKeys"> <bool key="EncodedWithXMLCoder">YES</bool> <string>dataController_</string> <string>eventCount_</string> @@ -2025,558 +2027,16 @@ <string key="minorKey">browser/cocoa/tab_strip_model_observer_bridge.h</string> </object> </object> - </object> - <object class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+"> - <bool key="EncodedWithXMLCoder">YES</bool> - <object class="IBPartialClassDescription"> - <string key="className">NSActionCell</string> - <string key="superclassName">NSCell</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSActionCell.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSApplication</string> - <string key="superclassName">NSResponder</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="91708435"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSApplication.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSApplication</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="245985208"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSApplicationScripting.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSApplication</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="21001340"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSColorPanel.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSApplication</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSHelpManager.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSApplication</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSPageLayout.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSApplication</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSUserInterfaceItemSearching.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSArrayController</string> - <string key="superclassName">NSObjectController</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSArrayController.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSButton</string> - <string key="superclassName">NSControl</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSButton.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSButtonCell</string> - <string key="superclassName">NSActionCell</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSCell</string> - <string key="superclassName">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSCell.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSControl</string> - <string key="superclassName">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="396340753"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSControl.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSController</string> - <string key="superclassName">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSController.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSFormatter</string> - <string key="superclassName">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSFormatter.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSMenu</string> - <string key="superclassName">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="364138646"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSMenu.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSAccessibility.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <reference key="sourceIdentifier" ref="91708435"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <reference key="sourceIdentifier" ref="245985208"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <reference key="sourceIdentifier" ref="21001340"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <reference key="sourceIdentifier" ref="396340753"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSDictionaryController.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSDragging.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSFontManager.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSFontPanel.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSKeyValueBinding.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <reference key="sourceIdentifier" ref="364138646"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSNibLoading.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSOutlineView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSPasteboard.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSSavePanel.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="444320675"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSTableView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSToolbarItem.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier" id="706871835"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSArchiver.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSClassDescription.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSError.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSFileManager.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSKeyValueCoding.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSKeyValueObserving.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSKeyedArchiver.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSObject.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSObjectScripting.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSPortCoder.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSRunLoop.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSScriptClassDescription.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSScriptKeyValueCoding.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSScriptObjectSpecifiers.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSScriptWhoseTests.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSThread.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSURL.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSURLConnection.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">Foundation.framework/Headers/NSURLDownload.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">QuartzCore.framework/Headers/CAAnimation.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">QuartzCore.framework/Headers/CALayer.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">QuartzCore.framework/Headers/CIImageProvider.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">SecurityInterface.framework/Headers/SFAuthorizationView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">SecurityInterface.framework/Headers/SFCertificatePanel.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">SecurityInterface.framework/Headers/SFChooseIdentityPanel.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSObjectController</string> - <string key="superclassName">NSController</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSObjectController.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSResponder</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSInterfaceStyle.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSResponder</string> - <string key="superclassName">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSScrollView</string> - <string key="superclassName">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSScrollView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSScroller</string> - <string key="superclassName">NSControl</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSScroller.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSTableColumn</string> - <string key="superclassName">NSObject</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSTableColumn.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSTableHeaderView</string> - <string key="superclassName">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSTableHeaderView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSTableView</string> - <string key="superclassName">NSControl</string> - <reference key="sourceIdentifier" ref="444320675"/> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSTextField</string> - <string key="superclassName">NSControl</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSTextField.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSTextFieldCell</string> - <string key="superclassName">NSActionCell</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSTextFieldCell.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSClipView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSMenuItem.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSView</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSRulerView.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSView</string> - <string key="superclassName">NSResponder</string> - <reference key="sourceIdentifier" ref="706871835"/> - </object> <object class="IBPartialClassDescription"> <string key="className">NSWindow</string> <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSDrawer.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSWindow</string> - <string key="superclassName">NSResponder</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSWindow.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSWindow</string> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSWindowScripting.h</string> - </object> - </object> - <object class="IBPartialClassDescription"> - <string key="className">NSWindowController</string> - <string key="superclassName">NSResponder</string> - <object class="NSMutableDictionary" key="actions"> - <string key="NS.key.0">showWindow:</string> - <string key="NS.object.0">id</string> - </object> - <object class="IBClassDescriptionSource" key="sourceIdentifier"> - <string key="majorKey">IBFrameworkSource</string> - <string key="minorKey">AppKit.framework/Headers/NSWindowController.h</string> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">browser/cocoa/nswindow_local_state.h</string> </object> </object> </object> </object> <int key="IBDocument.localizationMode">0</int> - <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults"> - <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string> - <integer value="1050" key="NS.object.0"/> - </object> - <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies"> - <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string> - <integer value="3000" key="NS.object.0"/> - </object> - <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> <string key="IBDocument.LastKnownRelativeProjectPath">../../chrome.xcodeproj</string> <int key="IBDocument.defaultPropertyAccessControl">3</int> </data> diff --git a/chrome/browser/app_controller_mac.h b/chrome/browser/app_controller_mac.h index 30f7b3c..44af869a 100644 --- a/chrome/browser/app_controller_mac.h +++ b/chrome/browser/app_controller_mac.h @@ -30,8 +30,8 @@ class Profile; // (and Browser*s). scoped_ptr<BookmarkMenuBridge> bookmarkMenuBridge_; scoped_ptr<HistoryMenuBridge> historyMenuBridge_; - scoped_nsobject<PreferencesWindowController> prefsController_; - scoped_nsobject<AboutWindowController> aboutController_; + PreferencesWindowController* prefsController_; // Weak. + AboutWindowController* aboutController_; // Weak. // URLs that need to be opened when the app is fully initialized. Because it's // only needed during early startup, it points to a valid vector during early diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index ea5f817..e313130 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -168,6 +168,10 @@ static bool g_is_opening_new_window = false; // dealloc'd, it will stop the RunLoop and fall back into main(). g_browser_process->ReleaseModule(); + // Close these off if they have open windows. + [prefsController_ close]; + [aboutController_ close]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; } @@ -693,12 +697,16 @@ static bool g_is_opening_new_window = false; // Called when the preferences window is closed. We use this to release the // window controller. -- (void)prefsWindowClosed:(NSNotification*)notify { - [[NSNotificationCenter defaultCenter] - removeObserver:self - name:kUserDoneEditingPrefsNotification - object:prefsController_.get()]; - prefsController_.reset(NULL); +- (void)prefsWindowClosed:(NSNotification*)notification { + NSWindow* window = [prefsController_ window]; + DCHECK([notification object] == window); + NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; + [defaultCenter removeObserver:self + name:NSWindowWillCloseNotification + object:window]; + // PreferencesWindowControllers are autoreleased in + // -[PreferencesWindowController windowWillClose:]. + prefsController_ = nil; } // Show the preferences window, or bring it to the front if it's already @@ -712,45 +720,49 @@ static bool g_is_opening_new_window = false; - (void)showPreferencesWindow:(id)sender page:(OptionsPage)page profile:(Profile*)profile { - if (prefsController_.get()) { + if (prefsController_) { [prefsController_ switchToPage:page animate:YES]; } else { - prefsController_.reset([[PreferencesWindowController alloc] - initWithProfile:profile - initialPage:page]); + prefsController_ = + [[PreferencesWindowController alloc] initWithProfile:profile + initialPage:page]; // Watch for a notification of when it goes away so that we can destroy // the controller. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(prefsWindowClosed:) - name:kUserDoneEditingPrefsNotification - object:prefsController_.get()]; + name:NSWindowWillCloseNotification + object:[prefsController_ window]]; } [prefsController_ showPreferences:sender]; } // Called when the about window is closed. We use this to release the // window controller. -- (void)aboutWindowClosed:(NSNotification*)notify { +- (void)aboutWindowClosed:(NSNotification*)notification { + NSWindow* window = [aboutController_ window]; + DCHECK(window == [notification object]); [[NSNotificationCenter defaultCenter] removeObserver:self - name:kUserClosedAboutNotification - object:aboutController_.get()]; - aboutController_.reset(nil); + name:NSWindowWillCloseNotification + object:window]; + // AboutWindowControllers are autoreleased in + // -[AboutWindowController windowWillClose:]. + aboutController_ = nil; } - (IBAction)orderFrontStandardAboutPanel:(id)sender { if (!aboutController_) { - aboutController_.reset([[AboutWindowController alloc] - initWithProfile:[self defaultProfile]]); + aboutController_ = + [[AboutWindowController alloc] initWithProfile:[self defaultProfile]]; // Watch for a notification of when it goes away so that we can destroy // the controller. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aboutWindowClosed:) - name:kUserClosedAboutNotification - object:aboutController_.get()]; + name:NSWindowWillCloseNotification + object:[aboutController_ window]]; } if (![[aboutController_ window] isVisible]) diff --git a/chrome/browser/cocoa/about_ipc_controller_unittest.mm b/chrome/browser/cocoa/about_ipc_controller_unittest.mm index cff2281..efe1a56 100644 --- a/chrome/browser/cocoa/about_ipc_controller_unittest.mm +++ b/chrome/browser/cocoa/about_ipc_controller_unittest.mm @@ -15,21 +15,19 @@ namespace { -class AboutIPCControllerTest : public PlatformTest { - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... +class AboutIPCControllerTest : public CocoaTest { }; TEST_F(AboutIPCControllerTest, TestFilter) { - scoped_nsobject<AboutIPCController> controller( - [[AboutIPCController alloc] init]); - [controller window]; // force nib load. + AboutIPCController* controller = [[AboutIPCController alloc] init]; + EXPECT_TRUE([controller window]); // force nib load. IPC::LogData data; // Make sure generic names do NOT get filtered. std::wstring names[] = { L"PluginProcessingIsMyLife", L"ViewMsgFoo", L"NPObjectHell" }; - for (unsigned int i = 0; i < arraysize(names); i++) { + for (size_t i = 0; i < arraysize(names); i++) { data.message_name = names[i]; scoped_nsobject<CocoaLogData> cdata([[CocoaLogData alloc] initWithLogData:data]); @@ -44,6 +42,7 @@ TEST_F(AboutIPCControllerTest, TestFilter) { EXPECT_TRUE([controller filterOut:cdata.get()]); [controller setDisplayViewMessages:YES]; EXPECT_FALSE([controller filterOut:cdata.get()]); + [controller close]; } } // namespace diff --git a/chrome/browser/cocoa/about_window_controller.h b/chrome/browser/cocoa/about_window_controller.h index 23e76e0..75c1ac6 100644 --- a/chrome/browser/cocoa/about_window_controller.h +++ b/chrome/browser/cocoa/about_window_controller.h @@ -10,10 +10,6 @@ @class BackgroundTileView; class Profile; -// kUserClosedAboutNotification is the name of the notification posted when -// the About window is closed. -extern const NSString* const kUserClosedAboutNotification; - // A window controller that handles the About box. @interface AboutWindowController : NSWindowController { @private diff --git a/chrome/browser/cocoa/about_window_controller.mm b/chrome/browser/cocoa/about_window_controller.mm index 52730e7..0b2b20f 100644 --- a/chrome/browser/cocoa/about_window_controller.mm +++ b/chrome/browser/cocoa/about_window_controller.mm @@ -72,9 +72,6 @@ void AttributedStringAppendHyperlink(NSMutableAttributedString* attr_str, @end // @interface AboutWindowController(Private) -const NSString* const kUserClosedAboutNotification = - @"UserClosedAboutNotification"; - @implementation AboutWindowController - (id)initWithProfile:(Profile*)profile { @@ -194,8 +191,7 @@ static BOOL recentShownInstallFailedStatus = NO; } - (void)windowWillClose:(NSNotification*)notification { - NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; - [center postNotificationName:kUserClosedAboutNotification object:self]; + [self autorelease]; } - (void)setUpdateThrobberMessage:(NSString*)message { diff --git a/chrome/browser/cocoa/about_window_controller_unittest.mm b/chrome/browser/cocoa/about_window_controller_unittest.mm index 8e84388..71ce7c7 100644 --- a/chrome/browser/cocoa/about_window_controller_unittest.mm +++ b/chrome/browser/cocoa/about_window_controller_unittest.mm @@ -31,17 +31,21 @@ void PostAutoupdateStatusNotification(AutoupdateStatus status, userInfo:dictionary]; } -class AboutWindowControllerTest : public PlatformTest { +class AboutWindowControllerTest : public CocoaTest { public: virtual void SetUp() { - PlatformTest::SetUp(); - about_window_controller_.reset([[AboutWindowController alloc] - initWithProfile:nil]); - // make sure the nib is loaded - [about_window_controller_ window]; + CocoaTest::SetUp(); + about_window_controller_ = + [[AboutWindowController alloc] initWithProfile:nil]; + EXPECT_TRUE([about_window_controller_ window]); } - scoped_nsobject<AboutWindowController> about_window_controller_; + virtual void TearDown() { + [about_window_controller_ close]; + CocoaTest::TearDown(); + } + + AboutWindowController* about_window_controller_; }; TEST_F(AboutWindowControllerTest, TestCopyright) { @@ -82,7 +86,7 @@ TEST_F(AboutWindowControllerTest, TestButton) { ASSERT_TRUE([button isEnabled]); // Make sure the button is hooked up - ASSERT_EQ([button target], about_window_controller_.get()); + ASSERT_EQ([button target], about_window_controller_); ASSERT_EQ([button action], @selector(updateNow:)); } diff --git a/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm index f9f0bd9..a4eb9b9 100644 --- a/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm +++ b/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm @@ -40,40 +40,36 @@ bool ClipboardContainsText(NSPasteboard* pb, NSString* cmp) { // TODO(shess): Very similar to AutocompleteTextFieldTest. Maybe // those can be shared. -class AutocompleteTextFieldEditorTest : public PlatformTest { +class AutocompleteTextFieldEditorTest : public CocoaTest { public: AutocompleteTextFieldEditorTest() : pb_([NSPasteboard pasteboardWithUniqueName]) { + } + + virtual void SetUp() { + CocoaTest::SetUp(); NSRect frame = NSMakeRect(0, 0, 50, 30); - field_.reset([[AutocompleteTextField alloc] initWithFrame:frame]); + scoped_nsobject<AutocompleteTextField> field( + [[AutocompleteTextField alloc] initWithFrame:frame]); + field_ = field.get(); [field_ setStringValue:@"Testing"]; [field_ setObserver:&field_observer_]; - [cocoa_helper_.contentView() addSubview:field_.get()]; + [[test_window() contentView] addSubview:field_]; // Arrange for |field_| to get the right field editor. window_delegate_.reset( [[AutocompleteTextFieldWindowTestDelegate alloc] init]); - [cocoa_helper_.window() setDelegate:window_delegate_.get()]; + [test_window() setDelegate:window_delegate_.get()]; // Get the field editor setup. - cocoa_helper_.makeFirstResponder(field_); - id editor = [field_.get() currentEditor]; - editor_.reset([static_cast<AutocompleteTextFieldEditor*>(editor) retain]); - } + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; + editor_ = static_cast<AutocompleteTextFieldEditor*>([field_ currentEditor]); - virtual void SetUp() { - EXPECT_TRUE(editor_.get() != nil); - EXPECT_TRUE( - [editor_.get() isKindOfClass:[AutocompleteTextFieldEditor class]]); + EXPECT_TRUE(editor_); + EXPECT_TRUE([editor_ isKindOfClass:[AutocompleteTextFieldEditor class]]); } - // The removeFromSuperview call is needed to prevent crashes in - // later tests. - // TODO(shess): -removeromSuperview should not be necessary. Fix - // it. Also in autocomplete_text_field_unittest.mm. virtual ~AutocompleteTextFieldEditorTest() { - [cocoa_helper_.window() setDelegate:nil]; - [field_ removeFromSuperview]; [pb_ releaseGlobally]; } @@ -82,22 +78,23 @@ class AutocompleteTextFieldEditorTest : public PlatformTest { return pb_; } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... - scoped_nsobject<AutocompleteTextFieldEditor> editor_; - scoped_nsobject<AutocompleteTextField> field_; + AutocompleteTextFieldEditor* editor_; + AutocompleteTextField* field_; MockAutocompleteTextFieldObserver field_observer_; scoped_nsobject<AutocompleteTextFieldWindowTestDelegate> window_delegate_; private: - NSPasteboard *pb_; + NSPasteboard* pb_; }; +TEST_VIEW(AutocompleteTextFieldEditorTest, field_); + // Test that the field editor is linked in correctly. TEST_F(AutocompleteTextFieldEditorTest, FirstResponder) { - EXPECT_EQ(editor_.get(), [field_ currentEditor]); - EXPECT_TRUE([editor_.get() isDescendantOf:field_.get()]); - EXPECT_EQ([editor_.get() delegate], field_.get()); - EXPECT_EQ([editor_.get() observer], [field_.get() observer]); + EXPECT_EQ(editor_, [field_ currentEditor]); + EXPECT_TRUE([editor_ isDescendantOf:field_]); + EXPECT_EQ([editor_ delegate], field_); + EXPECT_EQ([editor_ observer], [field_ observer]); } TEST_F(AutocompleteTextFieldEditorTest, CutCopyTest) { @@ -107,45 +104,27 @@ TEST_F(AutocompleteTextFieldEditorTest, CutCopyTest) { NSString* test_string_1 = @"astring"; NSString* test_string_2 = @"another string"; - [editor_.get() setRichText:YES]; + [editor_ setRichText:YES]; // Put some text on the clipboard. - [editor_.get() setString:test_string_1]; - [editor_.get() selectAll:nil]; - [editor_.get() alignRight:nil]; // Add a rich text attribute. + [editor_ setString:test_string_1]; + [editor_ selectAll:nil]; + [editor_ alignRight:nil]; // Add a rich text attribute. ASSERT_TRUE(NoRichTextOnClipboard(clipboard())); // Check that copying it works and we only get plain text. - [editor_.get() performCopy:clipboard()]; + [editor_ performCopy:clipboard()]; ASSERT_TRUE(NoRichTextOnClipboard(clipboard())); ASSERT_TRUE(ClipboardContainsText(clipboard(), test_string_1)); // Check that cutting it works and we only get plain text. - [editor_.get() setString:test_string_2]; - [editor_.get() selectAll:nil]; - [editor_.get() alignLeft:nil]; // Add a rich text attribute. - [editor_.get() performCut:clipboard()]; + [editor_ setString:test_string_2]; + [editor_ selectAll:nil]; + [editor_ alignLeft:nil]; // Add a rich text attribute. + [editor_ performCut:clipboard()]; ASSERT_TRUE(NoRichTextOnClipboard(clipboard())); ASSERT_TRUE(ClipboardContainsText(clipboard(), test_string_2)); - ASSERT_EQ([[editor_.get() textStorage] length], 0U); -} - -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(AutocompleteTextFieldEditorTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [field_ superview]); - - // TODO(shess): For some reason, -removeFromSuperview while |field_| - // is first-responder causes AutocompleteTextFieldWindowTestDelegate - // -windowWillReturnFieldEditor:toObject: to be passed an object of - // class AutocompleteTextFieldEditor. Which is weird. Changing - // first responder will remove the field editor. - cocoa_helper_.makeFirstResponder(nil); - EXPECT_FALSE([field_.get() currentEditor]); - EXPECT_FALSE([editor_.get() superview]); - - [field_.get() removeFromSuperview]; - EXPECT_FALSE([field_.get() superview]); + ASSERT_EQ([[editor_ textStorage] length], 0U); } // Test drawing, mostly to ensure nothing leaks or crashes. @@ -157,13 +136,13 @@ TEST_F(AutocompleteTextFieldEditorTest, Display) { // Test that -paste: is correctly delegated to the observer. TEST_F(AutocompleteTextFieldEditorTest, Paste) { EXPECT_CALL(field_observer_, OnPaste()); - [editor_.get() paste:nil]; + [editor_ paste:nil]; } // Test that -pasteAndGo: is correctly delegated to the observer. TEST_F(AutocompleteTextFieldEditorTest, PasteAndGo) { EXPECT_CALL(field_observer_, OnPasteAndGo()); - [editor_.get() pasteAndGo:nil]; + [editor_ pasteAndGo:nil]; } // Test that the menu is constructed correctly when CanPasteAndGo(). @@ -173,7 +152,7 @@ TEST_F(AutocompleteTextFieldEditorTest, CanPasteAndGoMenu) { EXPECT_CALL(field_observer_, GetPasteActionStringId()) .WillOnce(Return(IDS_PASTE_AND_GO)); - NSMenu* menu = [editor_.get() menuForEvent:nil]; + NSMenu* menu = [editor_ menuForEvent:nil]; NSArray* items = [menu itemArray]; ASSERT_EQ([items count], 6U); // TODO(shess): Check the titles, too? @@ -194,7 +173,7 @@ TEST_F(AutocompleteTextFieldEditorTest, CannotPasteAndGoMenu) { EXPECT_CALL(field_observer_, CanPasteAndGo()) .WillOnce(Return(false)); - NSMenu* menu = [editor_.get() menuForEvent:nil]; + NSMenu* menu = [editor_ menuForEvent:nil]; NSArray* items = [menu itemArray]; ASSERT_EQ([items count], 5U); // TODO(shess): Check the titles, too? @@ -212,8 +191,8 @@ TEST_F(AutocompleteTextFieldEditorTest, CannotPasteAndGoMenu) { // Test that the menu is constructed correctly when field isn't // editable. TEST_F(AutocompleteTextFieldEditorTest, CanPasteAndGoMenuNotEditable) { - [field_.get() setEditable:NO]; - [editor_.get() setEditable:NO]; + [field_ setEditable:NO]; + [editor_ setEditable:NO]; // Never call these when not editable. EXPECT_CALL(field_observer_, CanPasteAndGo()) @@ -221,7 +200,7 @@ TEST_F(AutocompleteTextFieldEditorTest, CanPasteAndGoMenuNotEditable) { EXPECT_CALL(field_observer_, GetPasteActionStringId()) .Times(0); - NSMenu* menu = [editor_.get() menuForEvent:nil]; + NSMenu* menu = [editor_ menuForEvent:nil]; NSArray* items = [menu itemArray]; ASSERT_EQ([items count], 3U); // TODO(shess): Check the titles, too? diff --git a/chrome/browser/cocoa/autocomplete_text_field_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm index 66574ee..928d005 100644 --- a/chrome/browser/cocoa/autocomplete_text_field_unittest.mm +++ b/chrome/browser/cocoa/autocomplete_text_field_unittest.mm @@ -68,29 +68,22 @@ NSEvent* Event(NSView* view, const NSPoint point, const NSEventType type) { // the time. static const CGFloat kWidth(300.0); -class AutocompleteTextFieldTest : public PlatformTest { +class AutocompleteTextFieldTest : public CocoaTest { public: AutocompleteTextFieldTest() { // Make sure this is wide enough to play games with the cell // decorations. NSRect frame = NSMakeRect(0, 0, kWidth, 30); - field_.reset([[AutocompleteTextField alloc] initWithFrame:frame]); + scoped_nsobject<AutocompleteTextField> field( + [[AutocompleteTextField alloc] initWithFrame:frame]); + field_ = field.get(); [field_ setStringValue:@"Test test"]; [field_ setObserver:&field_observer_]; - [cocoa_helper_.contentView() addSubview:field_.get()]; + [[test_window() contentView] addSubview:field_]; window_delegate_.reset( [[AutocompleteTextFieldWindowTestDelegate alloc] init]); - [cocoa_helper_.window() setDelegate:window_delegate_.get()]; - } - - // The removeFromSuperview call is needed to prevent crashes in - // later tests. - // TODO(shess): -removeromSuperview should not be necessary. Fix - // it. Also in autocomplete_text_field_editor_unittest.mm. - ~AutocompleteTextFieldTest() { - [cocoa_helper_.window() setDelegate:nil]; - [field_ removeFromSuperview]; + [test_window() setDelegate:window_delegate_.get()]; } NSEvent* KeyDownEventWithFlags(NSUInteger flags) { @@ -98,7 +91,7 @@ class AutocompleteTextFieldTest : public PlatformTest { location:NSZeroPoint modifierFlags:flags timestamp:0.0 - windowNumber:[cocoa_helper_.window() windowNumber] + windowNumber:[test_window() windowNumber] context:nil characters:@"a" charactersIgnoringModifiers:@"a" @@ -108,10 +101,10 @@ class AutocompleteTextFieldTest : public PlatformTest { // Helper to return the field-editor frame being used w/in |field_|. NSRect EditorFrame() { - EXPECT_TRUE([field_.get() currentEditor]); - EXPECT_EQ([[field_.get() subviews] count], 1U); - if ([[field_.get() subviews] count] > 0) { - return [[[field_.get() subviews] objectAtIndex:0] frame]; + EXPECT_TRUE([field_ currentEditor]); + EXPECT_EQ([[field_ subviews] count], 1U); + if ([[field_ subviews] count] > 0) { + return [[[field_ subviews] objectAtIndex:0] frame]; } else { // Return something which won't work so the caller can soldier // on. @@ -119,25 +112,18 @@ class AutocompleteTextFieldTest : public PlatformTest { } } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... - scoped_nsobject<AutocompleteTextField> field_; + AutocompleteTextField* field_; MockAutocompleteTextFieldObserver field_observer_; scoped_nsobject<AutocompleteTextFieldWindowTestDelegate> window_delegate_; }; +TEST_VIEW(AutocompleteTextFieldTest, field_); + // Test that we have the right cell class. TEST_F(AutocompleteTextFieldTest, CellClass) { EXPECT_TRUE([[field_ cell] isKindOfClass:[AutocompleteTextFieldCell class]]); } -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(AutocompleteTextFieldTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [field_ superview]); - [field_.get() removeFromSuperview]; - EXPECT_FALSE([field_ superview]); -} - // Test that we get the same cell from -cell and // -autocompleteTextFieldCell. TEST_F(AutocompleteTextFieldTest, Cell) { @@ -150,10 +136,10 @@ TEST_F(AutocompleteTextFieldTest, Cell) { TEST_F(AutocompleteTextFieldTest, FirstResponder) { EXPECT_EQ(nil, [field_ currentEditor]); EXPECT_EQ([[field_ subviews] count], 0U); - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; EXPECT_FALSE(nil == [field_ currentEditor]); EXPECT_EQ([[field_ subviews] count], 1U); - EXPECT_TRUE([[field_ currentEditor] isDescendantOf:field_.get()]); + EXPECT_TRUE([[field_ currentEditor] isDescendantOf:field_]); // Check that the window delegate is providing the right editor. Class c = [AutocompleteTextFieldEditor class]; @@ -199,9 +185,9 @@ TEST_F(AutocompleteTextFieldTest, Display) { [field_ display]; // Test focussed drawing. - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; [field_ display]; - cocoa_helper_.clearFirstResponder(); + [test_window() clearPretendKeyWindowAndFirstResponder]; // Test display of various cell configurations. AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; @@ -239,7 +225,7 @@ TEST_F(AutocompleteTextFieldTest, FlagsChanged) { // field catches -flagsChanged: because it's on the responder chain, // the field editor doesn't implement it. TEST_F(AutocompleteTextFieldTest, FieldEditorFlagsChanged) { - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; NSResponder* firstResponder = [[field_ window] firstResponder]; EXPECT_EQ(firstResponder, [field_ currentEditor]); @@ -270,7 +256,7 @@ TEST_F(AutocompleteTextFieldTest, ResetFieldEditorBase) { // Capture the editor frame resulting from the standard focus // machinery. - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; const NSRect baseEditorFrame(EditorFrame()); // Setting a hint should result in a strictly smaller editor frame. @@ -301,7 +287,7 @@ TEST_F(AutocompleteTextFieldTest, ResetFieldEditorSearchHint) { // machinery. [cell setSearchHintString:kHintString availableWidth:kWidth]; EXPECT_TRUE([cell hintString]); - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; const NSRect baseEditorFrame(EditorFrame()); // Clearing the hint should result in a strictly larger editor @@ -336,7 +322,7 @@ TEST_F(AutocompleteTextFieldTest, ResetFieldEditorKeywordHint) { partialString:kPartialString availableWidth:kWidth]; EXPECT_TRUE([cell keywordString]); - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; const NSRect baseEditorFrame(EditorFrame()); // Clearing the hint should result in a strictly larger editor @@ -371,7 +357,7 @@ TEST_F(AutocompleteTextFieldTest, ResetFieldEditorBlocksEndEditing) { [field_ setDelegate:mockDelegate]; // Becoming first responder doesn't begin editing. - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); EXPECT_TRUE(nil != editor); [mockDelegate verify]; @@ -385,7 +371,7 @@ TEST_F(AutocompleteTextFieldTest, ResetFieldEditorBlocksEndEditing) { BOOL yes = YES; [[[mockDelegate expect] andReturnValue:OCMOCK_VALUE(yes)] control:OCMOCK_ANY textShouldEndEditing:OCMOCK_ANY]; - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; [mockDelegate verify]; [field_ setDelegate:nil]; @@ -425,7 +411,7 @@ TEST_F(AutocompleteTextFieldTest, ClickSearchHintPutsCaretRightmost) { // Can't rely on the window machinery to make us first responder, // here. - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; EXPECT_TRUE([field_ currentEditor]); const NSPoint point(NSMakePoint(300.0 - 20.0, 5.0)); @@ -450,7 +436,7 @@ TEST_F(AutocompleteTextFieldTest, ClickKeywordPutsCaretLeftmost) { // Can't rely on the window machinery to make us first responder, // here. - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; EXPECT_TRUE([field_ currentEditor]); const NSPoint point(NSMakePoint(20.0, 5.0)); @@ -468,7 +454,7 @@ TEST_F(AutocompleteTextFieldTest, ClickKeywordPutsCaretLeftmost) { TEST_F(AutocompleteTextFieldTest, ClickBorderSelectsAll) { // Can't rely on the window machinery to make us first responder, // here. - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; EXPECT_TRUE([field_ currentEditor]); const NSPoint point(NSMakePoint(20.0, 1.0)); @@ -621,7 +607,8 @@ TEST_F(AutocompleteTextFieldTest, SetAttributedStringBaseline) { EXPECT_TRUE([[field_ stringValue] isEqualToString:kString]); // Try that again with focus. - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; + EXPECT_TRUE([field_ currentEditor]); // Check that what we get back looks like what we put in. @@ -644,8 +631,7 @@ TEST_F(AutocompleteTextFieldTest, SetAttributedStringUndo) { scoped_nsobject<NSAttributedString> attributedString( [[NSAttributedString alloc] initWithString:kString attributes:attributes]); - - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; EXPECT_TRUE([field_ currentEditor]); NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); NSUndoManager* undoManager = [editor undoManager]; @@ -678,7 +664,7 @@ TEST_F(AutocompleteTextFieldTest, SetAttributedStringUndo) { } TEST_F(AutocompleteTextFieldTest, EditorGetsCorrectUndoManager) { - cocoa_helper_.makeFirstResponder(field_); + [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); EXPECT_TRUE(editor); diff --git a/chrome/browser/cocoa/autocomplete_text_field_unittest_helper.mm b/chrome/browser/cocoa/autocomplete_text_field_unittest_helper.mm index 5e3f4d8..3701a2b 100644 --- a/chrome/browser/cocoa/autocomplete_text_field_unittest_helper.mm +++ b/chrome/browser/cocoa/autocomplete_text_field_unittest_helper.mm @@ -11,17 +11,19 @@ @implementation AutocompleteTextFieldWindowTestDelegate - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject { - EXPECT_TRUE([anObject isKindOfClass:[AutocompleteTextField class]]); + id editor = nil; + if ([anObject isKindOfClass:[AutocompleteTextField class]]) { + if (editor_ == nil) { + editor_.reset([[AutocompleteTextFieldEditor alloc] init]); + } + EXPECT_TRUE(editor_ != nil); - if (editor_ == nil) { - editor_.reset([[AutocompleteTextFieldEditor alloc] init]); + // This needs to be called every time, otherwise notifications + // aren't sent correctly. + [editor_ setFieldEditor:YES]; + editor = editor_.get(); } - EXPECT_TRUE(editor_ != nil); - - // This needs to be called every time, otherwise notifications - // aren't sent correctly. - [editor_ setFieldEditor:YES]; - return editor_; + return editor; } @end diff --git a/chrome/browser/cocoa/background_gradient_view_unittest.mm b/chrome/browser/cocoa/background_gradient_view_unittest.mm index 20ff6be..b0d0d5c 100644 --- a/chrome/browser/cocoa/background_gradient_view_unittest.mm +++ b/chrome/browser/cocoa/background_gradient_view_unittest.mm @@ -23,29 +23,23 @@ namespace { -class BackgroundGradientViewTest : public PlatformTest { +class BackgroundGradientViewTest : public CocoaTest { public: BackgroundGradientViewTest() { NSRect frame = NSMakeRect(0, 0, 100, 30); - view_.reset([[BackgroundGradientSubClassTest alloc] initWithFrame:frame]); - [cocoa_helper_.contentView() addSubview:view_.get()]; + scoped_nsobject<BackgroundGradientSubClassTest> view; + view.reset([[BackgroundGradientSubClassTest alloc] initWithFrame:frame]); + view_ = view.get(); + [[test_window() contentView] addSubview:view_]; } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... - scoped_nsobject<BackgroundGradientSubClassTest> view_; + BackgroundGradientSubClassTest* view_; }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(BackgroundGradientViewTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} +TEST_VIEW(BackgroundGradientViewTest, view_) // Test drawing, mostly to ensure nothing leaks or crashes. -TEST_F(BackgroundGradientViewTest, Display) { - [view_ display]; +TEST_F(BackgroundGradientViewTest, DisplayWithDivider) { [view_ setShowsDivider:YES]; [view_ display]; } diff --git a/chrome/browser/cocoa/background_tile_view_unittest.mm b/chrome/browser/cocoa/background_tile_view_unittest.mm index d225fca..8bc6d94 100644 --- a/chrome/browser/cocoa/background_tile_view_unittest.mm +++ b/chrome/browser/cocoa/background_tile_view_unittest.mm @@ -8,34 +8,27 @@ #import "chrome/browser/cocoa/background_tile_view.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" #include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" namespace { -class BackgroundTileViewTest : public testing::Test { +class BackgroundTileViewTest : public CocoaTest { public: BackgroundTileViewTest() { NSRect frame = NSMakeRect(0, 0, 100, 30); - view_.reset([[BackgroundTileView alloc] initWithFrame:frame]); - [cocoa_helper_.contentView() addSubview:view_.get()]; + scoped_nsobject<BackgroundTileView> view([[BackgroundTileView alloc] + initWithFrame:frame]); + view_ = view.get(); + [[test_window() contentView] addSubview:view_]; } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... - scoped_nsobject<BackgroundTileView> view_; + BackgroundTileView *view_; }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(BackgroundTileViewTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} +TEST_VIEW(BackgroundTileViewTest, view_) -// Test drawing, mostly to ensure nothing leaks or crashes. -TEST_F(BackgroundTileViewTest, Display) { - // Without image set. - [view_ display]; - // And now with an image. +// Test drawing with an Image +TEST_F(BackgroundTileViewTest, DisplayImage) { NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; [view_ setTileImage:image]; [view_ display]; diff --git a/chrome/browser/cocoa/base_view_unittest.mm b/chrome/browser/cocoa/base_view_unittest.mm index 6192055..bbfc75e 100644 --- a/chrome/browser/cocoa/base_view_unittest.mm +++ b/chrome/browser/cocoa/base_view_unittest.mm @@ -12,30 +12,19 @@ namespace { -class BaseViewTest : public PlatformTest { +class BaseViewTest : public CocoaTest { public: BaseViewTest() { NSRect frame = NSMakeRect(0, 0, 100, 100); - view_.reset([[BaseView alloc] initWithFrame:frame]); - [cocoa_helper_.contentView() addSubview:view_.get()]; + scoped_nsobject<BaseView> view([[BaseView alloc] initWithFrame:frame]); + view_ = view.get(); + [[test_window() contentView] addSubview:view_]; } - scoped_nsobject<BaseView> view_; - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... + BaseView* view_; // weak }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(BaseViewTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} - -// Test drawing, mostly to ensure nothing leaks or crashes. -TEST_F(BaseViewTest, Display) { - [view_ display]; -} +TEST_VIEW(BaseViewTest, view_) // Convert a rect in |view_|'s Cocoa coordinate system to gfx::Rect's top-left // coordinate system. Repeat the process in reverse and make sure we come out diff --git a/chrome/browser/cocoa/blocked_popup_container_controller_unittest.mm b/chrome/browser/cocoa/blocked_popup_container_controller_unittest.mm index 40a3f3bd..7cb8615 100644 --- a/chrome/browser/cocoa/blocked_popup_container_controller_unittest.mm +++ b/chrome/browser/cocoa/blocked_popup_container_controller_unittest.mm @@ -28,6 +28,7 @@ class BlockedPopupContainerControllerTest : public RenderViewHostTestHarness { // separately and inject the bridge with a test-only Create() call. // Unfortunate, but no way around it. RenderViewHostTestHarness::SetUp(); + CocoaTest::BootstrapCocoa(); cocoa_controller_ = [[BlockedPopupContainerController alloc] initWithContainer:nil]; EXPECT_TRUE([cocoa_controller_ bridge]); @@ -62,7 +63,6 @@ class BlockedPopupContainerControllerTest : public RenderViewHostTestHarness { } base::ScopedNSAutoreleasePool pool; - CocoaTestHelper cocoa_helper_; BlockedPopupContainer* container_; BlockedPopupContainerController* cocoa_controller_; }; diff --git a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm index 0fc68e3..8c14dee 100644 --- a/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_controller_unittest.mm @@ -84,7 +84,7 @@ namespace { static const int kContentAreaHeight = 500; static const int kInfoBarViewHeight = 30; -class BookmarkBarControllerTest : public PlatformTest { +class BookmarkBarControllerTest : public CocoaTest { public: BookmarkBarControllerTest() { resizeDelegate_.reset([[ViewResizerPong alloc] init]); @@ -139,9 +139,8 @@ class BookmarkBarControllerTest : public PlatformTest { return menu_item_; } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... - scoped_nsobject<NSView> parent_view_; BrowserTestHelper helper_; + scoped_nsobject<NSView> parent_view_; scoped_nsobject<ViewResizerPong> resizeDelegate_; scoped_nsobject<BookmarkBarControllerNoOpen> bar_; scoped_nsobject<BookmarkMenu> menu_; diff --git a/chrome/browser/cocoa/bookmark_bar_toolbar_view_unittest.mm b/chrome/browser/cocoa/bookmark_bar_toolbar_view_unittest.mm index 7a55edc..6c71275 100644 --- a/chrome/browser/cocoa/bookmark_bar_toolbar_view_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_toolbar_view_unittest.mm @@ -101,28 +101,23 @@ class MockThemeProvider : public ThemeProvider { - (CGFloat)detachedMorphProgress { return 1; } @end -class BookmarkBarToolbarViewTest : public PlatformTest { +class BookmarkBarToolbarViewTest : public CocoaTest { public: BookmarkBarToolbarViewTest() { controller_.reset([[DrawDetachedBarFakeController alloc] init]); NSRect frame = NSMakeRect(0, 0, 400, 40); - view_.reset([[BookmarkBarToolbarView alloc] initWithFrame:frame]); - [cocoa_helper_.contentView() addSubview:view_.get()]; - [view_.get() setController:controller_.get()]; + scoped_nsobject<BookmarkBarToolbarView> view( + [[BookmarkBarToolbarView alloc] initWithFrame:frame]); + view_ = view.get(); + [[test_window() contentView] addSubview:view_]; + [view_ setController:controller_.get()]; } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... scoped_nsobject<DrawDetachedBarFakeController> controller_; - scoped_nsobject<BookmarkBarToolbarView> view_; + BookmarkBarToolbarView* view_; }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(BookmarkBarToolbarViewTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} +TEST_VIEW(BookmarkBarToolbarViewTest, view_) // Test drawing (part 1), mostly to ensure nothing leaks or crashes. TEST_F(BookmarkBarToolbarViewTest, DisplayAsNormalBar) { diff --git a/chrome/browser/cocoa/bookmark_bar_view_unittest.mm b/chrome/browser/cocoa/bookmark_bar_view_unittest.mm index 4091168..c4f48ae 100644 --- a/chrome/browser/cocoa/bookmark_bar_view_unittest.mm +++ b/chrome/browser/cocoa/bookmark_bar_view_unittest.mm @@ -66,18 +66,21 @@ namespace { class BookmarkBarViewTest : public CocoaTest { public: + virtual void SetUp() { + CocoaTest::SetUp(); + view_.reset([[BookmarkBarView alloc] init]); + } + scoped_nsobject<BookmarkBarView> view_; }; TEST_F(BookmarkBarViewTest, CanDragWindow) { - view_.reset([[BookmarkBarView alloc] init]); - EXPECT_FALSE([view_.get() mouseDownCanMoveWindow]); + EXPECT_FALSE([view_ mouseDownCanMoveWindow]); } TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDrop) { - view_.reset([[BookmarkBarView alloc] init]); scoped_nsobject<FakeBookmarkDraggingInfo> - info([[FakeBookmarkDraggingInfo alloc] init]); + info([[FakeBookmarkDraggingInfo alloc] init]); [view_ setController:info.get()]; EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); diff --git a/chrome/browser/cocoa/bookmark_button_cell_unittest.mm b/chrome/browser/cocoa/bookmark_button_cell_unittest.mm index aabe1af..a1b7b40 100644 --- a/chrome/browser/cocoa/bookmark_button_cell_unittest.mm +++ b/chrome/browser/cocoa/bookmark_button_cell_unittest.mm @@ -11,20 +11,17 @@ namespace { -class BookmarkButtonCellTest : public PlatformTest { - public: - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... - scoped_nsobject<NSButton> view_; +class BookmarkButtonCellTest : public CocoaTest { }; // Make sure it's not totally bogus TEST_F(BookmarkButtonCellTest, SizeForBounds) { NSRect frame = NSMakeRect(0, 0, 50, 30); - view_.reset([[NSButton alloc] initWithFrame:frame]); - scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc] - initTextCell:@"Testing"]); - [view_ setCell:cell.get()]; - [cocoa_helper_.contentView() addSubview:view_.get()]; + scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); + scoped_nsobject<BookmarkButtonCell> cell( + [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); + [view setCell:cell.get()]; + [[test_window() contentView] addSubview:view]; NSRect r = NSMakeRect(0, 0, 100, 100); NSSize size = [cell.get() cellSizeForBounds:r]; @@ -34,8 +31,8 @@ TEST_F(BookmarkButtonCellTest, SizeForBounds) { // Make sure the default from the base class is overridden TEST_F(BookmarkButtonCellTest, MouseEnterStuff) { - scoped_nsobject<BookmarkButtonCell> cell([[BookmarkButtonCell alloc] - initTextCell:@"Testing"]); + scoped_nsobject<BookmarkButtonCell> cell( + [[BookmarkButtonCell alloc] initTextCell:@"Testing"]); EXPECT_TRUE([cell.get() showsBorderOnlyWhileMouseInside]); } diff --git a/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm b/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm index 4e88619..47d06d3 100644 --- a/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm +++ b/chrome/browser/cocoa/bookmark_name_folder_controller_unittest.mm @@ -11,9 +11,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" -class BookmarkNameFolderControllerTest : public PlatformTest { +class BookmarkNameFolderControllerTest : public CocoaTest { public: - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... BrowserTestHelper helper_; }; @@ -26,7 +25,7 @@ TEST_F(BookmarkNameFolderControllerTest, AddNew) { scoped_nsobject<BookmarkNameFolderController> controller([[BookmarkNameFolderController alloc] - initWithParentWindow:cocoa_helper_.window() + initWithParentWindow:test_window() profile:helper_.profile() node:node]); [controller window]; // force nib load @@ -56,7 +55,7 @@ TEST_F(BookmarkNameFolderControllerTest, AddNewDefaultName) { scoped_nsobject<BookmarkNameFolderController> controller([[BookmarkNameFolderController alloc] - initWithParentWindow:cocoa_helper_.window() + initWithParentWindow:test_window() profile:helper_.profile() node:NULL]); [controller window]; // force nib load @@ -79,7 +78,7 @@ TEST_F(BookmarkNameFolderControllerTest, Rename) { // the node. scoped_nsobject<BookmarkNameFolderController> controller([[BookmarkNameFolderController alloc] - initWithParentWindow:cocoa_helper_.window() + initWithParentWindow:test_window() profile:helper_.profile() node:folder]); [controller window]; // force nib load @@ -100,7 +99,7 @@ TEST_F(BookmarkNameFolderControllerTest, EditAndConfirmOKButton) { scoped_nsobject<BookmarkNameFolderController> controller([[BookmarkNameFolderController alloc] - initWithParentWindow:cocoa_helper_.window() + initWithParentWindow:test_window() profile:helper_.profile() node:node]); [controller window]; // force nib load diff --git a/chrome/browser/cocoa/browser_window_cocoa_unittest.mm b/chrome/browser/cocoa/browser_window_cocoa_unittest.mm index 059be46..c6b5ea4 100644 --- a/chrome/browser/cocoa/browser_window_cocoa_unittest.mm +++ b/chrome/browser/cocoa/browser_window_cocoa_unittest.mm @@ -20,9 +20,8 @@ class BrowserWindowCocoaPong : public BrowserWindowCocoa { public: BrowserWindowCocoaPong(Browser* browser, - BrowserWindowController* controller, - NSWindow* window) : - BrowserWindowCocoa(browser, controller, window) { + BrowserWindowController* controller) : + BrowserWindowCocoa(browser, controller, [controller window]) { pong_ = false; } virtual ~BrowserWindowCocoaPong() { } @@ -39,36 +38,33 @@ class BrowserWindowCocoaPong : public BrowserWindowCocoa { }; // Main test class. -class BrowserWindowCocoaTest : public testing::Test { - +class BrowserWindowCocoaTest : public CocoaTest { virtual void SetUp() { - controller_.reset([[BrowserWindowController alloc] - initWithBrowser:browser_helper_.browser() - takeOwnership:NO]); + CocoaTest::SetUp(); + Browser* browser = browser_helper_.browser(); + controller_ = [[BrowserWindowController alloc] initWithBrowser:browser + takeOwnership:NO]; + } + + virtual void TearDown() { + [controller_ close]; + CocoaTest::TearDown(); } public: - // Order is very important here. We want the controller deleted - // before the pool, and want the pool deleted before - // BrowserTestHelper. - CocoaTestHelper cocoa_helper_; BrowserTestHelper browser_helper_; - base::ScopedNSAutoreleasePool pool_; - scoped_nsobject<BrowserWindowController> controller_; + BrowserWindowController* controller_; }; TEST_F(BrowserWindowCocoaTest, TestNotification) { - BrowserWindowCocoaPong *bwc = new BrowserWindowCocoaPong( - browser_helper_.browser(), - controller_.get(), - cocoa_helper_.window()); + BrowserWindowCocoaPong *bwc = + new BrowserWindowCocoaPong(browser_helper_.browser(), controller_); EXPECT_FALSE(bwc->pong_); bookmark_utils::ToggleWhenVisible(browser_helper_.profile()); // Confirm we are listening EXPECT_TRUE(bwc->pong_); - delete bwc; // If this does NOT crash it confirms we stopped listening in the destructor. bookmark_utils::ToggleWhenVisible(browser_helper_.profile()); @@ -78,8 +74,7 @@ TEST_F(BrowserWindowCocoaTest, TestNotification) { TEST_F(BrowserWindowCocoaTest, TestBookmarkBarVisible) { BrowserWindowCocoaPong *bwc = new BrowserWindowCocoaPong( browser_helper_.browser(), - controller_.get(), - cocoa_helper_.window()); + controller_); scoped_ptr<BrowserWindowCocoaPong> scoped_bwc(bwc); bool before = bwc->IsBookmarkBarVisible(); @@ -105,12 +100,10 @@ TEST_F(BrowserWindowCocoaTest, TestBookmarkBarVisible) { @end TEST_F(BrowserWindowCocoaTest, TestFullscreen) { - scoped_nsobject<FakeController> fake_controller_([[FakeController alloc] - init]); + FakeController* fake_controller = [[FakeController alloc] init]; BrowserWindowCocoaPong *bwc = new BrowserWindowCocoaPong( browser_helper_.browser(), - (BrowserWindowController*)fake_controller_.get(), - cocoa_helper_.window()); + (BrowserWindowController*)fake_controller); scoped_ptr<BrowserWindowCocoaPong> scoped_bwc(bwc); EXPECT_FALSE(bwc->IsFullscreen()); @@ -118,6 +111,7 @@ TEST_F(BrowserWindowCocoaTest, TestFullscreen) { EXPECT_TRUE(bwc->IsFullscreen()); bwc->SetFullscreen(false); EXPECT_FALSE(bwc->IsFullscreen()); + [fake_controller close]; } -/* TODO(???): test other methods of BrowserWindowCocoa */ +// TODO(???): test other methods of BrowserWindowCocoa diff --git a/chrome/browser/cocoa/clear_browsing_data_controller_unittest.mm b/chrome/browser/cocoa/clear_browsing_data_controller_unittest.mm index b26db74..ade7f91 100644 --- a/chrome/browser/cocoa/clear_browsing_data_controller_unittest.mm +++ b/chrome/browser/cocoa/clear_browsing_data_controller_unittest.mm @@ -17,9 +17,10 @@ namespace { -class ClearBrowsingDataControllerTest : public PlatformTest { +class ClearBrowsingDataControllerTest : public CocoaTest { public: - ClearBrowsingDataControllerTest() { + virtual void SetUp() { + CocoaTest::SetUp(); // Set up some interesting prefs: PrefService* prefs = helper_.profile()->GetPrefs(); prefs->SetBoolean(prefs::kDeleteBrowsingHistory, true); @@ -31,13 +32,17 @@ class ClearBrowsingDataControllerTest : public PlatformTest { prefs->SetInteger(prefs::kDeleteTimePeriod, BrowsingDataRemover::FOUR_WEEKS); - controller_.reset( - [[ClearBrowsingDataController alloc] initWithProfile:helper_.profile()]); + controller_ = + [[ClearBrowsingDataController alloc] initWithProfile:helper_.profile()]; + } + + virtual void TearDown() { + [controller_ close]; + CocoaTest::TearDown(); } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... BrowserTestHelper helper_; - scoped_nsobject<ClearBrowsingDataController> controller_; + ClearBrowsingDataController* controller_; }; TEST_F(ClearBrowsingDataControllerTest, InitialState) { diff --git a/chrome/browser/cocoa/clickhold_button_cell_unittest.mm b/chrome/browser/cocoa/clickhold_button_cell_unittest.mm index 80edfb4..99f5dcc 100644 --- a/chrome/browser/cocoa/clickhold_button_cell_unittest.mm +++ b/chrome/browser/cocoa/clickhold_button_cell_unittest.mm @@ -12,33 +12,22 @@ namespace { -class ClickHoldButtonCellTest : public PlatformTest { +class ClickHoldButtonCellTest : public CocoaTest { public: ClickHoldButtonCellTest() { NSRect frame = NSMakeRect(0, 0, 50, 30); - view_.reset([[NSButton alloc] initWithFrame:frame]); + scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); + view_ = view.get(); scoped_nsobject<ClickHoldButtonCell> cell( [[ClickHoldButtonCell alloc] initTextCell:@"Testing"]); [view_ setCell:cell.get()]; - [cocoa_helper_.contentView() addSubview:view_.get()]; + [[test_window() contentView] addSubview:view_]; } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc. - scoped_nsobject<NSButton> view_; + NSButton* view_; }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing leaks -// or crashes. -TEST_F(ClickHoldButtonCellTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} - -// Test drawing, mostly to ensure nothing leaks or crashes. -TEST_F(ClickHoldButtonCellTest, Display) { - [view_ display]; -} +TEST_VIEW(ClickHoldButtonCellTest, view_) // Test default values; make sure they are what they should be. TEST_F(ClickHoldButtonCellTest, Defaults) { diff --git a/chrome/browser/cocoa/download_shelf_view_unittest.mm b/chrome/browser/cocoa/download_shelf_view_unittest.mm index 1ddcc74..3fc015a 100644 --- a/chrome/browser/cocoa/download_shelf_view_unittest.mm +++ b/chrome/browser/cocoa/download_shelf_view_unittest.mm @@ -10,17 +10,14 @@ namespace { -class DownloadShelfViewTest : public PlatformTest { - public: - CocoaTestHelper cocoa_helper_; - scoped_nsobject<DownloadShelfView> view_; +class DownloadShelfViewTest : public CocoaTest { }; // This class only needs to do one thing: prevent mouse down events from moving // the parent window around. TEST_F(DownloadShelfViewTest, CanDragWindow) { - view_.reset([[DownloadShelfView alloc] init]); - EXPECT_FALSE([view_.get() mouseDownCanMoveWindow]); + scoped_nsobject<DownloadShelfView> view([[DownloadShelfView alloc] init]); + EXPECT_FALSE([view mouseDownCanMoveWindow]); } } // namespace diff --git a/chrome/browser/cocoa/event_utils_unittest.mm b/chrome/browser/cocoa/event_utils_unittest.mm index 662826c..ff12416 100644 --- a/chrome/browser/cocoa/event_utils_unittest.mm +++ b/chrome/browser/cocoa/event_utils_unittest.mm @@ -21,9 +21,7 @@ namespace { -class EventUtilsTest : public PlatformTest { - private: - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... +class EventUtilsTest : public CocoaTest { }; TEST_F(EventUtilsTest, TestWindowOpenDispositionFromNSEvent) { diff --git a/chrome/browser/cocoa/find_bar_cocoa_controller_unittest.mm b/chrome/browser/cocoa/find_bar_cocoa_controller_unittest.mm index 71614d8..c45c009 100644 --- a/chrome/browser/cocoa/find_bar_cocoa_controller_unittest.mm +++ b/chrome/browser/cocoa/find_bar_cocoa_controller_unittest.mm @@ -2,10 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import <Cocoa/Cocoa.h> - -#include "base/scoped_ptr.h" -#include "base/scoped_nsobject.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" #include "chrome/browser/browser_window.h" @@ -40,22 +36,20 @@ namespace { -class FindBarCocoaControllerTest : public PlatformTest { +class FindBarCocoaControllerTest : public CocoaTest { public: virtual void SetUp() { - PlatformTest::SetUp(); - - // TODO(rohitrao): We don't really need to do this once per test. - // Consider moving it to SetUpTestCase(). + CocoaTest::SetUp(); controller_.reset([[FindBarCocoaController alloc] init]); - [helper_.contentView() addSubview:[controller_ view]]; + [[test_window() contentView] addSubview:[controller_ view]]; } protected: - CocoaTestHelper helper_; scoped_nsobject<FindBarCocoaController> controller_; }; +TEST_VIEW(FindBarCocoaControllerTest, [controller_ view]) + TEST_F(FindBarCocoaControllerTest, ShowAndHide) { NSView* findBarView = [controller_ findBarView]; @@ -105,7 +99,7 @@ TEST_F(FindBarCocoaControllerTest, ResultLabelUpdatesCorrectly) { TEST_F(FindBarCocoaControllerTest, FindTextIsGlobal) { scoped_nsobject<FindBarCocoaController> otherController( [[FindBarCocoaController alloc] init]); - [helper_.contentView() addSubview:[otherController view]]; + [[test_window() contentView] addSubview:[otherController view]]; // Setting the text in one controller should update the other controller's // text as well. diff --git a/chrome/browser/cocoa/find_bar_view_unittest.mm b/chrome/browser/cocoa/find_bar_view_unittest.mm index c1fc902..5f83cda 100644 --- a/chrome/browser/cocoa/find_bar_view_unittest.mm +++ b/chrome/browser/cocoa/find_bar_view_unittest.mm @@ -27,30 +27,20 @@ namespace { -class FindBarViewTest : public PlatformTest { +class FindBarViewTest : public CocoaTest { public: FindBarViewTest() { NSRect frame = NSMakeRect(0, 0, 100, 30); - view_.reset([[FindBarView alloc] initWithFrame:frame]); - [cocoa_helper_.contentView() addSubview:view_.get()]; + scoped_nsobject<FindBarView> view( + [[FindBarView alloc] initWithFrame:frame]); + view_ = view.get(); + [[test_window() contentView] addSubview:view_]; } - scoped_nsobject<FindBarView> view_; - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... + FindBarView* view_; }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(FindBarViewTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} - -// Test drawing, mostly to ensure nothing leaks or crashes. -TEST_F(FindBarViewTest, Display) { - [view_ display]; -} +TEST_VIEW(FindBarViewTest, view_) TEST_F(FindBarViewTest, FindBarEatsMouseClicksInBackgroundArea) { MouseDownViewPong* pongView = @@ -63,15 +53,15 @@ TEST_F(FindBarViewTest, FindBarEatsMouseClicksInBackgroundArea) { [view_ setFrame:NSMakeRect(0, 0, 200, 200)]; // Add the pong view as a sibling of the findbar. - [cocoa_helper_.contentView() addSubview:pongView + [[test_window() contentView] addSubview:pongView positioned:NSWindowBelow - relativeTo:view_.get()]; + relativeTo:view_]; // Synthesize a mousedown event and send it to the window. The event is // placed in the center of the find bar. NSPoint pointInCenterOfFindBar = NSMakePoint(100, 100); [pongView setPong:NO]; - [cocoa_helper_.window() + [test_window() sendEvent:test_event_utils::LeftMouseDownAtPoint(pointInCenterOfFindBar)]; // Click gets eaten by findbar, not passed through to underlying view. EXPECT_FALSE([pongView pong]); @@ -83,16 +73,16 @@ TEST_F(FindBarViewTest, FindBarPassesThroughClicksInTransparentArea) { [view_ setFrame:NSMakeRect(0, 0, 200, 200)]; // Add the pong view as a sibling of the findbar. - [cocoa_helper_.contentView() addSubview:pongView + [[test_window() contentView] addSubview:pongView positioned:NSWindowBelow - relativeTo:view_.get()]; + relativeTo:view_]; // Synthesize a mousedown event and send it to the window. The event is inset // a few pixels from the lower left corner of the window, which places it in // the transparent area surrounding the findbar. NSPoint pointInTransparentArea = NSMakePoint(2, 2); [pongView setPong:NO]; - [cocoa_helper_.window() + [test_window() sendEvent:test_event_utils::LeftMouseDownAtPoint(pointInTransparentArea)]; // Click is ignored by findbar, passed through to underlying view. EXPECT_TRUE([pongView pong]); diff --git a/chrome/browser/cocoa/find_pasteboard_unittest.mm b/chrome/browser/cocoa/find_pasteboard_unittest.mm index abda115..3dcfb36 100644 --- a/chrome/browser/cocoa/find_pasteboard_unittest.mm +++ b/chrome/browser/cocoa/find_pasteboard_unittest.mm @@ -62,13 +62,12 @@ namespace { -class FindPasteboardTest : public PlatformTest { +class FindPasteboardTest : public CocoaTest { public: FindPasteboardTest() { pboard_.reset([[FindPasteboardTesting alloc] init]); } protected: - CocoaTestHelper helper_; scoped_nsobject<FindPasteboardTesting> pboard_; }; diff --git a/chrome/browser/cocoa/focus_tracker_unittest.mm b/chrome/browser/cocoa/focus_tracker_unittest.mm index 65ab91e..f2fb64f 100644 --- a/chrome/browser/cocoa/focus_tracker_unittest.mm +++ b/chrome/browser/cocoa/focus_tracker_unittest.mm @@ -12,79 +12,77 @@ namespace { -class FocusTrackerTest : public PlatformTest { +class FocusTrackerTest : public CocoaTest { public: virtual void SetUp() { - PlatformTest::SetUp(); - - viewA_.reset([[NSView alloc] initWithFrame:NSZeroRect]); - viewB_.reset([[NSView alloc] initWithFrame:NSZeroRect]); - [helper_.contentView() addSubview:viewA_.get()]; - [helper_.contentView() addSubview:viewB_.get()]; + CocoaTest::SetUp(); + scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:NSZeroRect]); + viewA_ = view.get(); + [[test_window() contentView] addSubview:viewA_]; + + view.reset([[NSView alloc] initWithFrame:NSZeroRect]); + viewB_ = view.get(); + [[test_window() contentView] addSubview:viewB_]; } protected: - CocoaTestHelper helper_; - scoped_nsobject<NSView> viewA_; - scoped_nsobject<NSView> viewB_; + NSView* viewA_; + NSView* viewB_; }; TEST_F(FocusTrackerTest, SaveRestore) { - NSWindow* window = helper_.window(); - ASSERT_TRUE([window makeFirstResponder:viewA_.get()]); - FocusTracker* tracker = - [[[FocusTracker alloc] initWithWindow:window] autorelease]; - + NSWindow* window = test_window(); + ASSERT_TRUE([window makeFirstResponder:viewA_]); + scoped_nsobject<FocusTracker> tracker( + [[FocusTracker alloc] initWithWindow:window]); // Give focus to |viewB_|, then try and restore it to view1. - ASSERT_TRUE([window makeFirstResponder:viewB_.get()]); + ASSERT_TRUE([window makeFirstResponder:viewB_]); EXPECT_TRUE([tracker restoreFocusInWindow:window]); - EXPECT_EQ(viewA_.get(), [window firstResponder]); + EXPECT_EQ(viewA_, [window firstResponder]); } TEST_F(FocusTrackerTest, SaveRestoreWithTextView) { // Valgrind will complain if the text field has zero size. NSRect frame = NSMakeRect(0, 0, 100, 20); - NSWindow* window = helper_.window(); - NSTextField* text = - [[[NSTextField alloc] initWithFrame:frame] autorelease]; - [helper_.contentView() addSubview:text]; + NSWindow* window = test_window(); + scoped_nsobject<NSTextField> text([[NSTextField alloc] initWithFrame:frame]); + [[window contentView] addSubview:text]; ASSERT_TRUE([window makeFirstResponder:text]); - FocusTracker* tracker = - [[[FocusTracker alloc] initWithWindow:window] autorelease]; - + scoped_nsobject<FocusTracker> tracker([[FocusTracker alloc] + initWithWindow:window]); // Give focus to |viewB_|, then try and restore it to the text field. - ASSERT_TRUE([window makeFirstResponder:viewB_.get()]); + ASSERT_TRUE([window makeFirstResponder:viewB_]); EXPECT_TRUE([tracker restoreFocusInWindow:window]); EXPECT_TRUE([[window firstResponder] isKindOfClass:[NSTextView class]]); } TEST_F(FocusTrackerTest, DontRestoreToViewNotInWindow) { - NSWindow* window = helper_.window(); - NSView* view3 = [[[NSView alloc] initWithFrame:NSZeroRect] autorelease]; - [helper_.contentView() addSubview:view3]; + NSWindow* window = test_window(); + scoped_nsobject<NSView> viewC([[NSView alloc] initWithFrame:NSZeroRect]); + [[window contentView] addSubview:viewC]; - ASSERT_TRUE([window makeFirstResponder:view3]); - FocusTracker* tracker = - [[[FocusTracker alloc] initWithWindow:window] autorelease]; + ASSERT_TRUE([window makeFirstResponder:viewC]); + scoped_nsobject<FocusTracker> tracker( + [[FocusTracker alloc] initWithWindow:window]); - // Give focus to |viewB_|, then remove view3 from the hierarchy and try + // Give focus to |viewB_|, then remove viewC from the hierarchy and try // to restore focus. The restore should fail. - ASSERT_TRUE([window makeFirstResponder:viewB_.get()]); - [view3 removeFromSuperview]; + ASSERT_TRUE([window makeFirstResponder:viewB_]); + [viewC removeFromSuperview]; EXPECT_FALSE([tracker restoreFocusInWindow:window]); } TEST_F(FocusTrackerTest, DontRestoreFocusToViewInDifferentWindow) { - NSWindow* window = helper_.window(); - ASSERT_TRUE([window makeFirstResponder:viewA_.get()]); - FocusTracker* tracker = - [[[FocusTracker alloc] initWithWindow:window] autorelease]; + NSWindow* window = test_window(); + ASSERT_TRUE([window makeFirstResponder:viewA_]); + scoped_nsobject<FocusTracker> tracker( + [[FocusTracker alloc] initWithWindow:window]); // Give focus to |viewB_|, then try and restore focus in a different // window. It is ok to pass a nil NSWindow here because we only use // it for direct comparison. - ASSERT_TRUE([window makeFirstResponder:viewB_.get()]); + ASSERT_TRUE([window makeFirstResponder:viewB_]); EXPECT_FALSE([tracker restoreFocusInWindow:nil]); } diff --git a/chrome/browser/cocoa/fullscreen_window_unittest.mm b/chrome/browser/cocoa/fullscreen_window_unittest.mm index fda2fc6..6d50f79 100644 --- a/chrome/browser/cocoa/fullscreen_window_unittest.mm +++ b/chrome/browser/cocoa/fullscreen_window_unittest.mm @@ -8,9 +8,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" -class FullscreenWindowTest : public PlatformTest { - public: - CocoaTestHelper cocoa_helper_; +class FullscreenWindowTest : public CocoaTest { }; TEST_F(FullscreenWindowTest, Basics) { @@ -21,8 +19,8 @@ TEST_F(FullscreenWindowTest, Basics) { EXPECT_TRUE([window_ canBecomeKeyWindow]); EXPECT_TRUE([window_ canBecomeMainWindow]); EXPECT_EQ(NSBorderlessWindowMask, [window_ styleMask]); - EXPECT_FALSE([window_ isReleasedWhenClosed]); EXPECT_TRUE(NSEqualRects([[NSScreen mainScreen] frame], [window_ frame])); + EXPECT_FALSE([window_ isReleasedWhenClosed]); } diff --git a/chrome/browser/cocoa/hyperlink_button_cell_unittest.mm b/chrome/browser/cocoa/hyperlink_button_cell_unittest.mm index bbcb202..16ed781 100644 --- a/chrome/browser/cocoa/hyperlink_button_cell_unittest.mm +++ b/chrome/browser/cocoa/hyperlink_button_cell_unittest.mm @@ -12,54 +12,44 @@ namespace { -class HyperlinkButtonCellTest : public PlatformTest { +class HyperlinkButtonCellTest : public CocoaTest { public: HyperlinkButtonCellTest() { NSRect frame = NSMakeRect(0, 0, 50, 30); - view_.reset([[NSButton alloc] initWithFrame:frame]); - cell_.reset([[HyperlinkButtonCell alloc] initTextCell:@"Testing"]); - [view_ setCell:cell_.get()]; - [cocoa_helper_.contentView() addSubview:view_.get()]; + scoped_nsobject<NSButton> view([[NSButton alloc] initWithFrame:frame]); + view_ = view.get(); + scoped_nsobject<HyperlinkButtonCell> cell( + [[HyperlinkButtonCell alloc] initTextCell:@"Testing"]); + cell_ = cell.get(); + [view_ setCell:cell_]; + [[test_window() contentView] addSubview:view_]; } - void TestCellCustomization() { - EXPECT_FALSE([cell_ isBordered]); + void TestCellCustomization(HyperlinkButtonCell* cell) { + EXPECT_FALSE([cell isBordered]); EXPECT_EQ(NSNoCellMask, [cell_ highlightsBy]); - EXPECT_TRUE([cell_ showsBorderOnlyWhileMouseInside]); - EXPECT_TRUE([cell_ textColor]); + EXPECT_TRUE([cell showsBorderOnlyWhileMouseInside]); + EXPECT_TRUE([cell textColor]); } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... - scoped_nsobject<NSButton> view_; - scoped_nsobject<HyperlinkButtonCell> cell_; + NSButton* view_; + HyperlinkButtonCell* cell_; }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(HyperlinkButtonCellTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} - -// Test drawing, mostly to ensure nothing leaks or crashes. -TEST_F(HyperlinkButtonCellTest, Display) { - [view_ display]; -} +TEST_VIEW(HyperlinkButtonCellTest, view_) // Tests the three designated intializers. TEST_F(HyperlinkButtonCellTest, Initializers) { - TestCellCustomization(); // |-initTextFrame:| - - cell_.reset([[HyperlinkButtonCell alloc] init]); - TestCellCustomization(); + TestCellCustomization(cell_); // |-initTextFrame:| + scoped_nsobject<HyperlinkButtonCell> cell([[HyperlinkButtonCell alloc] init]); + TestCellCustomization(cell.get()); // Need to create a dummy archiver to test |-initWithCoder:|. NSData* emptyData = [NSKeyedArchiver archivedDataWithRootObject:@""]; NSCoder* coder = [[[NSKeyedUnarchiver alloc] initForReadingWithData:emptyData] autorelease]; - cell_.reset([[HyperlinkButtonCell alloc] initWithCoder:coder]); - TestCellCustomization(); + cell.reset([[HyperlinkButtonCell alloc] initWithCoder:coder]); + TestCellCustomization(cell); } // Test set color. diff --git a/chrome/browser/cocoa/infobar_container_controller_unittest.mm b/chrome/browser/cocoa/infobar_container_controller_unittest.mm index f5a45b2..9808748 100644 --- a/chrome/browser/cocoa/infobar_container_controller_unittest.mm +++ b/chrome/browser/cocoa/infobar_container_controller_unittest.mm @@ -16,33 +16,32 @@ namespace { -class InfoBarContainerControllerTest : public PlatformTest { +class InfoBarContainerControllerTest : public CocoaTest { virtual void SetUp() { + CocoaTest::SetUp(); resizeDelegate_.reset([[ViewResizerPong alloc] init]); TabStripModel* model = browser_helper_.browser()->tabstrip_model(); - controller_.reset([[InfoBarContainerController alloc] - initWithTabStripModel:model - resizeDelegate:resizeDelegate_.get()]); + ViewResizerPong *viewResizer = resizeDelegate_.get(); + controller_ = + [[InfoBarContainerController alloc] initWithTabStripModel:model + resizeDelegate:viewResizer]; + NSView* view = [controller_ view]; + [[test_window() contentView] addSubview:view]; + } + + virtual void TearDown() { + [[controller_ view] removeFromSuperviewWithoutNeedingDisplay]; + [controller_ release]; + CocoaTest::TearDown(); } public: - // Order is very important here. We want the controller deleted - // before the pool, and want the pool deleted before - // BrowserTestHelper. - CocoaTestHelper cocoa_helper_; BrowserTestHelper browser_helper_; - base::ScopedNSAutoreleasePool pool_; scoped_nsobject<ViewResizerPong> resizeDelegate_; - scoped_nsobject<InfoBarContainerController> controller_; + InfoBarContainerController* controller_; }; -TEST_F(InfoBarContainerControllerTest, Show) { - // Make sure the container's view is non-nil and draws without crashing. - NSView* view = [controller_ view]; - EXPECT_TRUE(view != nil); - - [cocoa_helper_.contentView() addSubview:view]; -} +TEST_VIEW(InfoBarContainerControllerTest, [controller_ view]) TEST_F(InfoBarContainerControllerTest, BWCPong) { // Call positionInfoBarsAndResize and check that |resizeDelegate_| got a @@ -54,7 +53,6 @@ TEST_F(InfoBarContainerControllerTest, BWCPong) { TEST_F(InfoBarContainerControllerTest, AddAndRemoveInfoBars) { NSView* view = [controller_ view]; - [cocoa_helper_.contentView() addSubview:view]; // Add three infobars, one of each type, and then remove them. // After each step check to make sure we have the correct number of @@ -85,7 +83,6 @@ TEST_F(InfoBarContainerControllerTest, AddAndRemoveInfoBars) { TEST_F(InfoBarContainerControllerTest, RemoveAllInfoBars) { NSView* view = [controller_ view]; - [cocoa_helper_.contentView() addSubview:view]; // Add three infobars and then remove them all. MockAlertInfoBarDelegate alertDelegate; diff --git a/chrome/browser/cocoa/infobar_controller_unittest.mm b/chrome/browser/cocoa/infobar_controller_unittest.mm index 9a55d21..6dbfb5d 100644 --- a/chrome/browser/cocoa/infobar_controller_unittest.mm +++ b/chrome/browser/cocoa/infobar_controller_unittest.mm @@ -61,61 +61,58 @@ namespace { /////////////////////////////////////////////////////////////////////////// // Test fixtures -class AlertInfoBarControllerTest : public PlatformTest { +class AlertInfoBarControllerTest : public CocoaTest { public: virtual void SetUp() { - PlatformTest::SetUp(); + CocoaTest::SetUp(); controller_.reset( [[AlertInfoBarController alloc] initWithDelegate:&delegate_]); container_.reset( [[InfoBarContainerTest alloc] initWithController:controller_]); [controller_ setContainerController:container_]; - [helper_.contentView() addSubview:[controller_ view]]; + [[test_window() contentView] addSubview:[controller_ view]]; } protected: - CocoaTestHelper helper_; MockAlertInfoBarDelegate delegate_; scoped_nsobject<id> container_; scoped_nsobject<AlertInfoBarController> controller_; }; -class LinkInfoBarControllerTest : public PlatformTest { +class LinkInfoBarControllerTest : public CocoaTest { public: virtual void SetUp() { - PlatformTest::SetUp(); + CocoaTest::SetUp(); controller_.reset( [[LinkInfoBarController alloc] initWithDelegate:&delegate_]); container_.reset( [[InfoBarContainerTest alloc] initWithController:controller_]); [controller_ setContainerController:container_]; - [helper_.contentView() addSubview:[controller_ view]]; + [[test_window() contentView] addSubview:[controller_ view]]; } protected: - CocoaTestHelper helper_; MockLinkInfoBarDelegate delegate_; scoped_nsobject<id> container_; scoped_nsobject<LinkInfoBarController> controller_; }; -class ConfirmInfoBarControllerTest : public PlatformTest { +class ConfirmInfoBarControllerTest : public CocoaTest { public: virtual void SetUp() { - PlatformTest::SetUp(); + CocoaTest::SetUp(); controller_.reset( [[ConfirmInfoBarController alloc] initWithDelegate:&delegate_]); container_.reset( [[InfoBarContainerTest alloc] initWithController:controller_]); [controller_ setContainerController:container_]; - [helper_.contentView() addSubview:[controller_ view]]; + [[test_window() contentView] addSubview:[controller_ view]]; } protected: - CocoaTestHelper helper_; MockConfirmInfoBarDelegate delegate_; scoped_nsobject<id> container_; scoped_nsobject<ConfirmInfoBarController> controller_; @@ -125,6 +122,8 @@ class ConfirmInfoBarControllerTest : public PlatformTest { //////////////////////////////////////////////////////////////////////////// // Tests +TEST_VIEW(AlertInfoBarControllerTest, [controller_ view]); + TEST_F(AlertInfoBarControllerTest, ShowAndDismiss) { // Make sure someone looked at the message and icon. EXPECT_TRUE(delegate_.message_text_accessed); @@ -146,6 +145,8 @@ TEST_F(AlertInfoBarControllerTest, DeallocController) { EXPECT_FALSE(delegate_.closed); } +TEST_VIEW(LinkInfoBarControllerTest, [controller_ view]); + TEST_F(LinkInfoBarControllerTest, ShowAndDismiss) { // Make sure someone looked at the message, link, and icon. EXPECT_TRUE(delegate_.message_text_accessed); @@ -176,6 +177,8 @@ TEST_F(LinkInfoBarControllerTest, ShowAndClickLinkWithoutClosing) { EXPECT_FALSE(delegate_.closed); } +TEST_VIEW(ConfirmInfoBarControllerTest, [controller_ view]); + TEST_F(ConfirmInfoBarControllerTest, ShowAndDismiss) { // Make sure someone looked at the message and icon. EXPECT_TRUE(delegate_.message_text_accessed); diff --git a/chrome/browser/cocoa/infobar_text_field_unittest.mm b/chrome/browser/cocoa/infobar_text_field_unittest.mm index 5df9e3f..e9887acb 100644 --- a/chrome/browser/cocoa/infobar_text_field_unittest.mm +++ b/chrome/browser/cocoa/infobar_text_field_unittest.mm @@ -36,20 +36,23 @@ namespace { /////////////////////////////////////////////////////////////////////////// // Test fixtures -class InfoBarTextFieldTest : public PlatformTest { - protected: - CocoaTestHelper helper_; +class InfoBarTextFieldTest : public CocoaTest { + public: + InfoBarTextFieldTest() { + NSRect frame = NSMakeRect(0, 0, 200, 200); + scoped_nsobject<InfoBarTextField> field( + [[InfoBarTextField alloc] initWithFrame:frame]); + field_ = field.get(); + [[test_window() contentView] addSubview:field_]; + } + + InfoBarTextField* field_; }; //////////////////////////////////////////////////////////////////////////// // Tests -TEST_F(InfoBarTextFieldTest, Show) { - // Test basic drawing. - scoped_nsobject<InfoBarTextField> field( - [[InfoBarTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)]); - [helper_.contentView() addSubview:field]; -} +TEST_VIEW(InfoBarTextFieldTest, field_) TEST_F(InfoBarTextFieldTest, LinkClicked) { scoped_nsobject<InfoBarTextField> field( diff --git a/chrome/browser/cocoa/keyword_editor_cocoa_controller_unittest.mm b/chrome/browser/cocoa/keyword_editor_cocoa_controller_unittest.mm index 6f8eeb9..e551175 100644 --- a/chrome/browser/cocoa/keyword_editor_cocoa_controller_unittest.mm +++ b/chrome/browser/cocoa/keyword_editor_cocoa_controller_unittest.mm @@ -14,32 +14,47 @@ @interface FakeKeywordEditorController : KeywordEditorCocoaController { @public - BOOL changed_; + BOOL modelChanged_; } +- (void)modelChanged; +- (BOOL)hasModelChanged; - (KeywordEditorModelObserver*)observer; @end @implementation FakeKeywordEditorController + - (void)modelChanged { - changed_ = YES; + modelChanged_ = YES; +} + +- (BOOL)hasModelChanged { + return modelChanged_; } + - (KeywordEditorModelObserver*)observer { return observer_.get(); } + @end // TODO(rsesek): Figure out a good way to test this class (crbug.com/21640). namespace { -class KeywordEditorCocoaControllerTest : public PlatformTest { +class KeywordEditorCocoaControllerTest : public CocoaTest { public: - void SetUp() { + virtual void SetUp() { + CocoaTest::SetUp(); TestingProfile* profile = static_cast<TestingProfile*>(browser_helper_.profile()); profile->CreateTemplateURLModel(); - controller_.reset( - [[FakeKeywordEditorController alloc] initWithProfile:profile]); + + controller_ = [[FakeKeywordEditorController alloc] initWithProfile:profile]; + } + + virtual void TearDown() { + [controller_ close]; + CocoaTest::TearDown(); } // Helper to count the keyword editors. @@ -55,56 +70,15 @@ class KeywordEditorCocoaControllerTest : public PlatformTest { return count; } - CocoaTestHelper cocoa_helper_; BrowserTestHelper browser_helper_; - scoped_nsobject<FakeKeywordEditorController> controller_; + FakeKeywordEditorController* controller_; }; TEST_F(KeywordEditorCocoaControllerTest, TestModelChanged) { - EXPECT_FALSE(controller_.get()->changed_); + EXPECT_FALSE([controller_ hasModelChanged]); KeywordEditorModelObserver* observer = [controller_ observer]; observer->OnTemplateURLModelChanged(); - EXPECT_TRUE(controller_.get()->changed_); -} - -// Test that the window shows correctly, and the controller is -// released correctly. -TEST_F(KeywordEditorCocoaControllerTest, ShowAndCloseWindow) { - // |controller_| is the only reference. - EXPECT_EQ([controller_.get() retainCount], 1U); - - // TODO(shess): This test verifies that it leaks no windows. Work - // to push this expectation up into the unit testing framework. - - const NSUInteger initial_window_count([[NSApp windows] count]); - - // Explicit autorelease pool here because [NSApp windows] returns an - // autorelease immutable NSArray, which otherwise pins the window. - { - base::ScopedNSAutoreleasePool pool; - - // -showWindow: brings up the window (which retains - // |controller_|). - [controller_.get() showWindow:nil]; - EXPECT_EQ([[NSApp windows] count], initial_window_count+1); - - // In regular usage, our scoped reference would not exist and - // |controller_| would manage itself once -showWindow: is called. - // This means that we need another reference to balance things - // out. - [controller_.get() retain]; - - // Closing the window should leave us with the single reference. - [controller_.get() close]; - } - - // |controller_| still has a handle on the window, drop the last - // reference so we can check that we didn't leak a window. - EXPECT_EQ([controller_.get() retainCount], 1U); - controller_.reset(); - - // All created windows should be gone. - EXPECT_EQ([[NSApp windows] count], initial_window_count); + EXPECT_TRUE([controller_ hasModelChanged]); } // Test that +showKeywordEditor brings up the existing editor and diff --git a/chrome/browser/cocoa/location_bar_view_mac_unittest.mm b/chrome/browser/cocoa/location_bar_view_mac_unittest.mm index 8cbb3fb..aec948d 100644 --- a/chrome/browser/cocoa/location_bar_view_mac_unittest.mm +++ b/chrome/browser/cocoa/location_bar_view_mac_unittest.mm @@ -59,20 +59,21 @@ TEST_F(LocationBarViewMacTest, GetInputString) { namespace { -class LocationBarViewMacTest : public PlatformTest { +class LocationBarViewMacTest : public CocoaTest { public: LocationBarViewMacTest() { // Make sure this is wide enough to play games with the cell // decorations. NSRect frame = NSMakeRect(0, 0, 400.0, 30); - field_.reset([[AutocompleteTextField alloc] initWithFrame:frame]); + scoped_nsobject<AutocompleteTextField> field( + [[AutocompleteTextField alloc] initWithFrame:frame]); + field_ = field.get(); [field_ setStringValue:@"Testing"]; - [cocoa_helper_.contentView() addSubview:field_.get()]; + [[test_window() contentView] addSubview:field_]; } - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... BrowserTestHelper helper_; - scoped_nsobject<AutocompleteTextField> field_; + AutocompleteTextField* field_; }; TEST_F(LocationBarViewMacTest, OnChangedImpl) { @@ -90,25 +91,25 @@ TEST_F(LocationBarViewMacTest, OnChangedImpl) { // With no special hints requested, none set. LocationBarViewMac::OnChangedImpl( - field_.get(), std::wstring(), std::wstring(), false, false, image); + field_, std::wstring(), std::wstring(), false, false, image); EXPECT_FALSE([cell keywordString]); EXPECT_FALSE([cell hintString]); // Request only a search hint. LocationBarViewMac::OnChangedImpl( - field_.get(), std::wstring(), std::wstring(), false, true, image); + field_, std::wstring(), std::wstring(), false, true, image); EXPECT_FALSE([cell keywordString]); EXPECT_TRUE([[[cell hintString] string] isEqualToString:kSearchHint]); // Request a keyword hint, same results whether |search_hint| // parameter is true or false. LocationBarViewMac::OnChangedImpl( - field_.get(), kKeyword, kKeyword, true, true, image); + field_, kKeyword, kKeyword, true, true, image); EXPECT_FALSE([cell keywordString]); EXPECT_TRUE([[[cell hintString] string] hasPrefix:kKeywordPrefix]); EXPECT_TRUE([[[cell hintString] string] hasSuffix:kKeywordSuffix]); LocationBarViewMac::OnChangedImpl( - field_.get(), kKeyword, kKeyword, true, false, image); + field_, kKeyword, kKeyword, true, false, image); EXPECT_FALSE([cell keywordString]); EXPECT_TRUE([[[cell hintString] string] hasPrefix:kKeywordPrefix]); EXPECT_TRUE([[[cell hintString] string] hasSuffix:kKeywordSuffix]); @@ -116,11 +117,11 @@ TEST_F(LocationBarViewMacTest, OnChangedImpl) { // Request keyword-search mode, same results whether |search_hint| // parameter is true or false. LocationBarViewMac::OnChangedImpl( - field_.get(), kKeyword, kKeyword, false, true, image); + field_, kKeyword, kKeyword, false, true, image); EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kKeywordString]); EXPECT_FALSE([cell hintString]); LocationBarViewMac::OnChangedImpl( - field_.get(), kKeyword, kKeyword, false, false, image); + field_, kKeyword, kKeyword, false, false, image); EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kKeywordString]); EXPECT_FALSE([cell hintString]); @@ -132,13 +133,13 @@ TEST_F(LocationBarViewMacTest, OnChangedImpl) { frame.size.width = 10.0; [field_ setFrame:frame]; LocationBarViewMac::OnChangedImpl( - field_.get(), kKeyword, kKeyword, false, true, image); + field_, kKeyword, kKeyword, false, true, image); EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kPartialString]); EXPECT_FALSE([cell hintString]); // Transition back to baseline. LocationBarViewMac::OnChangedImpl( - field_.get(), std::wstring(), std::wstring(), false, false, image); + field_, std::wstring(), std::wstring(), false, false, image); EXPECT_FALSE([cell keywordString]); EXPECT_FALSE([cell hintString]); } diff --git a/chrome/browser/cocoa/nswindow_local_state_unittest.mm b/chrome/browser/cocoa/nswindow_local_state_unittest.mm index 6d4fab1..ccd4628 100644 --- a/chrome/browser/cocoa/nswindow_local_state_unittest.mm +++ b/chrome/browser/cocoa/nswindow_local_state_unittest.mm @@ -12,21 +12,26 @@ #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" -class NSWindowLocalStateTest : public PlatformTest { +class NSWindowLocalStateTest : public CocoaTest { virtual void SetUp() { + CocoaTest::SetUp(); path_ = L"NSWindowLocalStateTest"; - window_.reset( + window_ = [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 20, 20) styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered - defer:NO]); + defer:NO]; browser_helper_.profile()->GetPrefs()->RegisterDictionaryPref(path_); } + virtual void TearDown() { + [window_ close]; + CocoaTest::TearDown(); + } + public: - CocoaTestHelper cocoa_helper_; BrowserTestHelper browser_helper_; - scoped_nsobject<NSWindow> window_; + NSWindow* window_; const wchar_t* path_; }; diff --git a/chrome/browser/cocoa/page_info_window_controller_unittest.mm b/chrome/browser/cocoa/page_info_window_controller_unittest.mm index 8c92098..8ca4782 100644 --- a/chrome/browser/cocoa/page_info_window_controller_unittest.mm +++ b/chrome/browser/cocoa/page_info_window_controller_unittest.mm @@ -2,37 +2,36 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import <Cocoa/Cocoa.h> - #include "base/scoped_nsobject.h" #import "chrome/browser/cocoa/page_info_window_controller.h" #include "chrome/browser/cocoa/browser_test_helper.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" -#include "chrome/common/pref_names.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "testing/platform_test.h" -class PageInfoWindowControllerTest : public PlatformTest { +class PageInfoWindowControllerTest : public CocoaTest { virtual void SetUp() { - controller_.reset([[PageInfoWindowController alloc] init]); + CocoaTest::SetUp(); + controller_ = [[PageInfoWindowController alloc] init]; + EXPECT_TRUE([controller_ window]); + } + + virtual void TearDown() { + [controller_ close]; + CocoaTest::TearDown(); } public: - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... BrowserTestHelper helper_; - scoped_nsobject<PageInfoWindowController> controller_; + PageInfoWindowController* controller_; }; TEST_F(PageInfoWindowControllerTest, TestImages) { - [controller_ window]; // Force nib load. EXPECT_TRUE([controller_ goodImg]); EXPECT_TRUE([controller_ badImg]); } TEST_F(PageInfoWindowControllerTest, TestGrow) { - [controller_ window]; // Force nib load. NSRect frame = [[controller_ window] frame]; [controller_ setShowHistoryBox:YES]; NSRect newFrame = [[controller_ window] frame]; @@ -42,7 +41,6 @@ TEST_F(PageInfoWindowControllerTest, TestGrow) { TEST_F(PageInfoWindowControllerTest, TestShrink) { - [controller_ window]; // Force nib to load. [controller_ setShowHistoryBox:YES]; NSRect frame = [[controller_ window] frame]; [controller_ setShowHistoryBox:NO]; diff --git a/chrome/browser/cocoa/preferences_window_controller.h b/chrome/browser/cocoa/preferences_window_controller.h index 6028269..8380538 100644 --- a/chrome/browser/cocoa/preferences_window_controller.h +++ b/chrome/browser/cocoa/preferences_window_controller.h @@ -135,9 +135,6 @@ class ProfileSyncService; // Usable from cocoa bindings to hook up the custom home pages table. @property(readonly) CustomHomePagesModel* customPagesSource; -// NSNotification sent when the prefs window is closed. -extern NSString* const kUserDoneEditingPrefsNotification; - @end @interface PreferencesWindowController(Testing) diff --git a/chrome/browser/cocoa/preferences_window_controller.mm b/chrome/browser/cocoa/preferences_window_controller.mm index 7bb62c8..2137d2d 100644 --- a/chrome/browser/cocoa/preferences_window_controller.mm +++ b/chrome/browser/cocoa/preferences_window_controller.mm @@ -46,9 +46,6 @@ #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" -NSString* const kUserDoneEditingPrefsNotification = - @"kUserDoneEditingPrefsNotification"; - namespace { std::wstring GetNewTabUIURLString() { @@ -1621,10 +1618,7 @@ const int kDisabledIndex = 1; // We've hit a recalcitrant field editor, force it to go away. [[self window] endEditingFor:nil]; } - - [[NSNotificationCenter defaultCenter] - postNotificationName:kUserDoneEditingPrefsNotification - object:self]; + [self autorelease]; } - (void)controlTextDidEndEditing:(NSNotification*)notification { diff --git a/chrome/browser/cocoa/preferences_window_controller_unittest.mm b/chrome/browser/cocoa/preferences_window_controller_unittest.mm index 0853f94..cd47d5c 100644 --- a/chrome/browser/cocoa/preferences_window_controller_unittest.mm +++ b/chrome/browser/cocoa/preferences_window_controller_unittest.mm @@ -41,19 +41,19 @@ class PrefsControllerTest : public CocoaTest { PrefService* prefs = browser_helper_.profile()->GetPrefs(); prefs->RegisterBooleanPref(prefs::kMetricsReportingEnabled, false); - pref_controller_.reset([[PreferencesWindowController alloc] - initWithProfile:browser_helper_.profile() - initialPage:OPTIONS_PAGE_DEFAULT]); - EXPECT_TRUE(pref_controller_.get()); + pref_controller_ = [[PreferencesWindowController alloc] + initWithProfile:browser_helper_.profile() + initialPage:OPTIONS_PAGE_DEFAULT]; + EXPECT_TRUE(pref_controller_); } virtual void TearDown() { - pref_controller_.reset(NULL); + [pref_controller_ close]; CocoaTest::TearDown(); } BrowserTestHelper browser_helper_; - scoped_nsobject<PreferencesWindowController> pref_controller_; + PreferencesWindowController* pref_controller_; }; // Test showing the preferences window and making sure it's visible, then @@ -64,14 +64,17 @@ TEST_F(PrefsControllerTest, ShowAndClose) { scoped_nsobject<PrefsClosedObserver> observer( [[PrefsClosedObserver alloc] init]); - [[NSNotificationCenter defaultCenter] - addObserver:observer.get() - selector:@selector(prefsWindowClosed:) - name:kUserDoneEditingPrefsNotification - object:pref_controller_.get()]; + NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter]; + [defaultCenter addObserver:observer.get() + selector:@selector(prefsWindowClosed:) + name:NSWindowWillCloseNotification + object:[pref_controller_ window]]; [[pref_controller_ window] performClose:observer]; EXPECT_TRUE(observer.get()->gotNotification_); - [[NSNotificationCenter defaultCenter] removeObserver:observer.get()]; + [defaultCenter removeObserver:observer.get()]; + + // Prevent pref_controller_ from being closed again in TearDown() + pref_controller_ = nil; } TEST_F(PrefsControllerTest, ValidateCustomHomePagesTable) { diff --git a/chrome/browser/cocoa/styled_text_field_cell_unittest.mm b/chrome/browser/cocoa/styled_text_field_cell_unittest.mm index 5928d43..c087d28 100644 --- a/chrome/browser/cocoa/styled_text_field_cell_unittest.mm +++ b/chrome/browser/cocoa/styled_text_field_cell_unittest.mm @@ -38,7 +38,6 @@ class StyledTextFieldCellTest : public CocoaTest { [[test_window() contentView] addSubview:view_]; } - //CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... NSTextField* view_; StyledTextFieldTestCell* cell_; }; diff --git a/chrome/browser/cocoa/tab_controller_unittest.mm b/chrome/browser/cocoa/tab_controller_unittest.mm index 4616a9c..26484b5 100644 --- a/chrome/browser/cocoa/tab_controller_unittest.mm +++ b/chrome/browser/cocoa/tab_controller_unittest.mm @@ -63,17 +63,15 @@ namespace { // The dragging code in TabView makes heavy use of autorelease pools so -// inherit from Platform test to have one created for us. -class TabControllerTest : public PlatformTest { +// inherit from CocoaTest to have one created for us. +class TabControllerTest : public CocoaTest { public: TabControllerTest() { } - - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... }; // Tests creating the controller, sticking it in a window, and removing it. TEST_F(TabControllerTest, Creation) { - NSWindow* window = cocoa_helper_.window(); + NSWindow* window = test_window(); scoped_nsobject<TabController> controller([[TabController alloc] init]); [[window contentView] addSubview:[controller view]]; EXPECT_TRUE([controller tabView]); @@ -85,7 +83,7 @@ TEST_F(TabControllerTest, Creation) { // Tests sending it a close message and ensuring that the target/action get // called. Mimics the user clicking on the close button in the tab. TEST_F(TabControllerTest, Close) { - NSWindow* window = cocoa_helper_.window(); + NSWindow* window = test_window(); scoped_nsobject<TabController> controller([[TabController alloc] init]); [[window contentView] addSubview:[controller view]]; @@ -103,7 +101,7 @@ TEST_F(TabControllerTest, Close) { // Tests setting the |selected| property via code. TEST_F(TabControllerTest, APISelection) { - NSWindow* window = cocoa_helper_.window(); + NSWindow* window = test_window(); scoped_nsobject<TabController> controller([[TabController alloc] init]); [[window contentView] addSubview:[controller view]]; @@ -116,7 +114,7 @@ TEST_F(TabControllerTest, APISelection) { // Tests that setting the title of a tab sets the tooltip as well. TEST_F(TabControllerTest, ToolTip) { - NSWindow* window = cocoa_helper_.window(); + NSWindow* window = test_window(); scoped_nsobject<TabController> controller([[TabController alloc] init]); [[window contentView] addSubview:[controller view]]; @@ -129,7 +127,7 @@ TEST_F(TabControllerTest, ToolTip) { // Tests setting the |loading| property via code. TEST_F(TabControllerTest, Loading) { - NSWindow* window = cocoa_helper_.window(); + NSWindow* window = test_window(); scoped_nsobject<TabController> controller([[TabController alloc] init]); [[window contentView] addSubview:[controller view]]; @@ -152,7 +150,7 @@ TEST_F(TabControllerTest, Loading) { // we can dependency-inject/mock so it has very simple click behavior for unit // testing. TEST_F(TabControllerTest, UserSelection) { - NSWindow* window = cocoa_helper_.window(); + NSWindow* window = test_window(); // Create a tab at a known location in the window that we can click on // to activate selection. @@ -201,7 +199,7 @@ TEST_F(TabControllerTest, UserSelection) { } TEST_F(TabControllerTest, IconCapacity) { - NSWindow* window = cocoa_helper_.window(); + NSWindow* window = test_window(); scoped_nsobject<TabController> controller([[TabController alloc] init]); [[window contentView] addSubview:[controller view]]; int cap = [controller iconCapacity]; @@ -215,7 +213,7 @@ TEST_F(TabControllerTest, IconCapacity) { } TEST_F(TabControllerTest, ShouldShowIcon) { - NSWindow* window = cocoa_helper_.window(); + NSWindow* window = test_window(); scoped_nsobject<TabController> controller([[TabController alloc] init]); [[window contentView] addSubview:[controller view]]; int cap = [controller iconCapacity]; diff --git a/chrome/browser/cocoa/tab_strip_view_unittest.mm b/chrome/browser/cocoa/tab_strip_view_unittest.mm index d1a7007..635d3c2 100644 --- a/chrome/browser/cocoa/tab_strip_view_unittest.mm +++ b/chrome/browser/cocoa/tab_strip_view_unittest.mm @@ -12,29 +12,19 @@ namespace { -class TabStripViewTest : public PlatformTest { +class TabStripViewTest : public CocoaTest { public: TabStripViewTest() { NSRect frame = NSMakeRect(0, 0, 100, 30); - view_.reset([[TabStripView alloc] initWithFrame:frame]); - [cocoa_helper_.contentView() addSubview:view_.get()]; + scoped_nsobject<TabStripView> view( + [[TabStripView alloc] initWithFrame:frame]); + view_ = view.get(); + [[test_window() contentView] addSubview:view_]; } - scoped_nsobject<TabStripView> view_; - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... + TabStripView* view_; }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(TabStripViewTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} - -// Test drawing, mostly to ensure nothing leaks or crashes. -TEST_F(TabStripViewTest, Display) { - [view_ display]; -} +TEST_VIEW(TabStripViewTest, view_) } // namespace diff --git a/chrome/browser/cocoa/tab_view_unittest.mm b/chrome/browser/cocoa/tab_view_unittest.mm index ac73789..18b3fe5 100644 --- a/chrome/browser/cocoa/tab_view_unittest.mm +++ b/chrome/browser/cocoa/tab_view_unittest.mm @@ -12,25 +12,19 @@ namespace { -class TabViewTest : public PlatformTest { +class TabViewTest : public CocoaTest { public: TabViewTest() { NSRect frame = NSMakeRect(0, 0, 50, 30); - view_.reset([[TabView alloc] initWithFrame:frame]); - [cocoa_helper_.contentView() addSubview:view_.get()]; + scoped_nsobject<TabView> view([[TabView alloc] initWithFrame:frame]); + view_ = view.get(); + [[test_window() contentView] addSubview:view_]; } - scoped_nsobject<TabView> view_; - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... + TabView* view_; }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(TabViewTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} +TEST_VIEW(TabViewTest, view_) // Test drawing, mostly to ensure nothing leaks or crashes. TEST_F(TabViewTest, Display) { diff --git a/chrome/browser/cocoa/throbber_view_unittest.mm b/chrome/browser/cocoa/throbber_view_unittest.mm index caee8b1..469a9b8 100644 --- a/chrome/browser/cocoa/throbber_view_unittest.mm +++ b/chrome/browser/cocoa/throbber_view_unittest.mm @@ -14,32 +14,19 @@ namespace { -class ThrobberViewTest : public PlatformTest { +class ThrobberViewTest : public CocoaTest { public: ThrobberViewTest() { NSRect frame = NSMakeRect(10, 10, 16, 16); NSImage* image = ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_THROBBER); - view_.reset([[ThrobberView filmstripThrobberViewWithFrame:frame - image:image] retain]); - [cocoa_helper_.contentView() addSubview:view_.get()]; + view_ = [ThrobberView filmstripThrobberViewWithFrame:frame image:image]; + [[test_window() contentView] addSubview:view_]; } - scoped_nsobject<ThrobberView> view_; - CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... + ThrobberView* view_; }; -// Test adding/removing from the view hierarchy, mostly to ensure nothing -// leaks or crashes. -TEST_F(ThrobberViewTest, AddRemove) { - EXPECT_EQ(cocoa_helper_.contentView(), [view_ superview]); - [view_.get() removeFromSuperview]; - EXPECT_FALSE([view_ superview]); -} - -// Test drawing, mostly to ensure nothing leaks or crashes. -TEST_F(ThrobberViewTest, Display) { - [view_ display]; -} +TEST_VIEW(ThrobberViewTest, view_) } // namespace diff --git a/chrome/browser/cocoa/toolbar_controller_unittest.mm b/chrome/browser/cocoa/toolbar_controller_unittest.mm index 94e800c..a8be5fc 100644 --- a/chrome/browser/cocoa/toolbar_controller_unittest.mm +++ b/chrome/browser/cocoa/toolbar_controller_unittest.mm @@ -89,10 +89,6 @@ class ToolbarControllerTest : public CocoaTest { TEST_VIEW(ToolbarControllerTest, [bar_ view]) -///////////////////////////////////////////////////////////////////// -// TODO(dmaclach) All tests disabled due to crashing: crbug.com/27920 -///////////////////////////////////////////////////////////////////// - // Test the initial state that everything is sync'd up TEST_F(ToolbarControllerTest, InitialState) { CommandUpdater* updater = helper_.browser()->command_updater(); diff --git a/chrome/browser/cocoa/toolbar_view_unittest.mm b/chrome/browser/cocoa/toolbar_view_unittest.mm index 1b2c499..2026cad 100644 --- a/chrome/browser/cocoa/toolbar_view_unittest.mm +++ b/chrome/browser/cocoa/toolbar_view_unittest.mm @@ -10,17 +10,14 @@ namespace { -class ToolbarViewTest : public PlatformTest { - public: - CocoaTestHelper cocoa_helper_; - scoped_nsobject<ToolbarView> view_; +class ToolbarViewTest : public CocoaTest { }; // This class only needs to do one thing: prevent mouse down events from moving // the parent window around. TEST_F(ToolbarViewTest, CanDragWindow) { - view_.reset([[ToolbarView alloc] init]); - EXPECT_FALSE([view_.get() mouseDownCanMoveWindow]); + scoped_nsobject<ToolbarView> view([[ToolbarView alloc] init]); + EXPECT_FALSE([view mouseDownCanMoveWindow]); } } // namespace diff --git a/chrome/browser/cocoa/web_drop_target_unittest.mm b/chrome/browser/cocoa/web_drop_target_unittest.mm index 45bae3e..03ad5c8 100644 --- a/chrome/browser/cocoa/web_drop_target_unittest.mm +++ b/chrome/browser/cocoa/web_drop_target_unittest.mm @@ -13,13 +13,10 @@ class WebDropTargetTest : public RenderViewHostTestHarness { public: - WebDropTargetTest() { - drop_target_.reset([[WebDropTarget alloc] initWithTabContents:contents()]); - } - - virtual ~WebDropTargetTest() { - RenderViewHostTestHarness::TearDown(); - + virtual void SetUp() { + RenderViewHostTestHarness::SetUp(); + CocoaTest::BootstrapCocoa(); + drop_target_.reset([[WebDropTarget alloc] initWithTabContents:contents()]); } void PutURLOnPasteboard(NSString* urlString, NSPasteboard* pboard) { @@ -31,7 +28,6 @@ class WebDropTargetTest : public RenderViewHostTestHarness { } base::ScopedNSAutoreleasePool pool_; - CocoaTestHelper cocoa_helper_; scoped_nsobject<WebDropTarget> drop_target_; }; @@ -43,12 +39,13 @@ TEST_F(WebDropTargetTest, Init) { // Test flipping of coordinates given a point in window coordinates. TEST_F(WebDropTargetTest, Flip) { NSPoint windowPoint = NSZeroPoint; + scoped_nsobject<NSWindow> window([[CocoaTestHelperWindow alloc] init]); NSPoint viewPoint = [drop_target_ flipWindowPointToView:windowPoint - view:cocoa_helper_.contentView()]; + view:[window contentView]]; NSPoint screenPoint = [drop_target_ flipWindowPointToScreen:windowPoint - view:cocoa_helper_.contentView()]; + view:[window contentView]]; EXPECT_EQ(viewPoint.x, 0); EXPECT_EQ(viewPoint.y, 600); EXPECT_EQ(screenPoint.x, 0); |