aboutsummaryrefslogtreecommitdiff
path: root/UnitTesting
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-04-15 19:45:40 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-04-15 19:45:40 +0000
commitb8787b78e65a3b1ed18c406b0e2ea5232af7ac14 (patch)
tree91f8fdd516e97bec098e78081e8fd34e65eb432a /UnitTesting
parentf19d4cb3d479776d13e245009761d52841a09870 (diff)
[Author: dmaclach]
Added GTMUILocalizer for localizing UIs. 100% code coverage from tests. DELTA=1956 (1940 added, 8 deleted, 8 changed) R=thomasvl
Diffstat (limited to 'UnitTesting')
-rw-r--r--UnitTesting/GTMAppKit+UnitTesting.h6
-rw-r--r--UnitTesting/GTMAppKit+UnitTesting.m50
-rw-r--r--UnitTesting/GTMUIUnitTestingHarness/English.lproj/Localizable.stringsbin0 -> 1372 bytes
-rw-r--r--UnitTesting/GTMUIUnitTestingHarness/English.lproj/MainMenu.xib77
-rw-r--r--UnitTesting/TestData/GTMUnitTestingTestApp.gtmUTState26
-rw-r--r--UnitTesting/TestData/GTMUnitTestingWindow.gtmUTState20
6 files changed, 160 insertions, 19 deletions
diff --git a/UnitTesting/GTMAppKit+UnitTesting.h b/UnitTesting/GTMAppKit+UnitTesting.h
index 016da7e..1d6a08a 100644
--- a/UnitTesting/GTMAppKit+UnitTesting.h
+++ b/UnitTesting/GTMAppKit+UnitTesting.h
@@ -49,6 +49,12 @@
@interface NSMenuItem (GTMUnitTestingAdditions)
@end
+@interface NSTabView (GTMUnitTestingAdditions)
+@end
+
+@interface NSTabViewItem (GTMUnitTestingAdditions)
+@end
+
@protocol GTMUnitTestViewDrawer;
// Fails when the |a1|'s drawing in an area |a2| does not equal the image file named |a3|.
diff --git a/UnitTesting/GTMAppKit+UnitTesting.m b/UnitTesting/GTMAppKit+UnitTesting.m
index c35d07d..b3247fd 100644
--- a/UnitTesting/GTMAppKit+UnitTesting.m
+++ b/UnitTesting/GTMAppKit+UnitTesting.m
@@ -234,6 +234,43 @@ GTM_METHOD_CHECK(NSObject, gtm_unitTestEncodeState:);
@end
+@implementation NSTabView (GTMUnitTestingAdditions)
+
+// Encodes the state of an object in a manner suitable for comparing
+// against a master state file so we can determine whether the
+// object is in a suitable state.
+//
+// Arguments:
+// inCoder - the coder to encode our state into
+- (void)gtm_unitTestEncodeState:(NSCoder*)inCoder {
+ [super gtm_unitTestEncodeState:inCoder];
+ NSTabViewItem *tab = nil;
+ int i = 0;
+ GTM_FOREACH_OBJECT(tab, [self tabViewItems]) {
+ NSString *key = [NSString stringWithFormat:@"TabItem %d", i];
+ [inCoder encodeObject:tab forKey:key];
+ i = i + 1;
+ }
+}
+
+@end
+
+@implementation NSTabViewItem (GTMUnitTestingAdditions)
+
+// Encodes the state of an object in a manner suitable for comparing
+// against a master state file so we can determine whether the
+// object is in a suitable state.
+//
+// Arguments:
+// inCoder - the coder to encode our state into
+- (void)gtm_unitTestEncodeState:(NSCoder*)inCoder {
+ [super gtm_unitTestEncodeState:inCoder];
+ [inCoder encodeObject:[self label] forKey:@"TabLabel"];
+ [inCoder encodeObject:[self view] forKey:@"TabView"];
+}
+
+@end
+
// A view that allows you to delegate out drawing using the formal
// GTMUnitTestViewDelegate protocol above. This is useful when writing up unit
// tests for visual elements.
@@ -327,6 +364,19 @@ GTM_METHOD_CHECK(NSObject, gtm_unitTestEncodeState:);
- (void)gtm_unitTestEncodeState:(NSCoder*)inCoder {
[super gtm_unitTestEncodeState:inCoder];
[inCoder encodeBool:[self isHidden] forKey:@"ViewIsHidden"];
+ [inCoder encodeObject:[self toolTip] forKey:@"ViewToolTip"];
+ NSArray *supportedAttrs = [self accessibilityAttributeNames];
+ if ([supportedAttrs containsObject:NSAccessibilityHelpAttribute]) {
+ NSString *help
+ = [self accessibilityAttributeValue:NSAccessibilityHelpAttribute];
+ [inCoder encodeObject:help forKey:@"ViewAccessibilityHelp"];
+ }
+ if ([supportedAttrs containsObject:NSAccessibilityDescriptionAttribute]) {
+ NSString *description
+ = [self accessibilityAttributeValue:NSAccessibilityDescriptionAttribute];
+ [inCoder encodeObject:description forKey:@"ViewAccessibilityDescription"];
+ }
+
if ([self gtm_shouldEncodeStateForSubviews]) {
NSView *subview = nil;
int i = 0;
diff --git a/UnitTesting/GTMUIUnitTestingHarness/English.lproj/Localizable.strings b/UnitTesting/GTMUIUnitTestingHarness/English.lproj/Localizable.strings
new file mode 100644
index 0000000..6eb49a5
--- /dev/null
+++ b/UnitTesting/GTMUIUnitTestingHarness/English.lproj/Localizable.strings
Binary files differ
diff --git a/UnitTesting/GTMUIUnitTestingHarness/English.lproj/MainMenu.xib b/UnitTesting/GTMUIUnitTestingHarness/English.lproj/MainMenu.xib
index 6cef0cb..2a5aa22 100644
--- a/UnitTesting/GTMUIUnitTestingHarness/English.lproj/MainMenu.xib
+++ b/UnitTesting/GTMUIUnitTestingHarness/English.lproj/MainMenu.xib
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="29"/>
+ <integer value="377"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -611,7 +611,7 @@
</object>
<object class="NSMenuItem" id="626404410">
<reference key="NSMenu" ref="649796088"/>
- <string key="NSTitle">Format</string>
+ <string type="base64-UTF8" key="NSTitle">wqxNZW51IFRpdGxlA</string>
<string key="NSKeyEquiv"/>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
@@ -619,12 +619,12 @@
<reference key="NSMixedImage" ref="513340101"/>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="502084290">
- <string key="NSTitle">Format</string>
+ <string type="base64-UTF8" key="NSTitle">wqxNZW51IFRpdGxlA</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMenuItem" id="519768076">
+ <object class="NSMenuItem" id="83534624">
<reference key="NSMenu" ref="502084290"/>
- <string key="NSTitle">Show Fonts</string>
+ <string type="base64-UTF8" key="NSTitle">wqxNZW51IEl0ZW0</string>
<string key="NSKeyEquiv">t</string>
<int key="NSKeyEquivModMask">1048576</int>
<int key="NSMnemonicLoc">2147483647</int>
@@ -705,6 +705,9 @@
</object>
<string key="NSName">_NSMainMenu</string>
</object>
+ <object class="NSCustomObject" id="728136523">
+ <string key="NSClassName">GTMUILocalizer</string>
+ </object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
@@ -997,6 +1000,14 @@
</object>
<int key="connectionID">374</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">owner_</string>
+ <reference key="source" ref="728136523"/>
+ <reference key="destination" ref="1021"/>
+ </object>
+ <int key="connectionID">376</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -1472,17 +1483,12 @@
<reference key="object" ref="502084290"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="519768076"/>
<reference ref="1028416764"/>
+ <reference ref="83534624"/>
</object>
<reference key="parent" ref="626404410"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">344</int>
- <reference key="object" ref="519768076"/>
- <reference key="parent" ref="502084290"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">345</int>
<reference key="object" ref="1028416764"/>
<reference key="parent" ref="502084290"/>
@@ -1556,6 +1562,16 @@
<reference key="object" ref="708854459"/>
<reference key="parent" ref="698887838"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">375</int>
+ <reference key="object" ref="728136523"/>
+ <reference key="parent" ref="1049"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">377</int>
+ <reference key="object" ref="83534624"/>
+ <reference key="parent" ref="502084290"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1624,6 +1640,7 @@
<string>203.ImportedFromIB2</string>
<string>204.IBPluginDependency</string>
<string>204.ImportedFromIB2</string>
+ <string>205.IBEditorWindowLastContentRect</string>
<string>205.IBPluginDependency</string>
<string>205.ImportedFromIB2</string>
<string>205.editorWindowContentRectSynchronizationRect</string>
@@ -1675,9 +1692,9 @@
<string>297.IBPluginDependency</string>
<string>298.IBPluginDependency</string>
<string>299.IBPluginDependency</string>
+ <string>300.IBEditorWindowLastContentRect</string>
<string>300.IBPluginDependency</string>
<string>300.editorWindowContentRectSynchronizationRect</string>
- <string>344.IBPluginDependency</string>
<string>345.IBPluginDependency</string>
<string>346.IBPluginDependency</string>
<string>346.ImportedFromIB2</string>
@@ -1692,6 +1709,8 @@
<string>351.ImportedFromIB2</string>
<string>354.IBPluginDependency</string>
<string>354.ImportedFromIB2</string>
+ <string>375.IBPluginDependency</string>
+ <string>377.IBPluginDependency</string>
<string>56.IBPluginDependency</string>
<string>56.ImportedFromIB2</string>
<string>57.IBEditorWindowLastContentRect</string>
@@ -1789,6 +1808,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
+ <string>{{186, 593}, {243, 243}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{187, 434}, {243, 243}}</string>
@@ -1828,7 +1848,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{0, 1092}, {407, 20}}</string>
+ <string>{{2560, 1536}, {442, 20}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{74, 862}</string>
@@ -1840,11 +1860,11 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>{{2790, 1493}, {176, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{231, 634}, {176, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
@@ -1858,6 +1878,8 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{12, 909}, {245, 183}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1881,7 +1903,7 @@
<reference ref="9"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
- <string>{{144, 889}, {199, 203}}</string>
+ <string>{{144, 633}, {199, 203}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
<string>{{145, 474}, {199, 203}}</string>
@@ -1911,7 +1933,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">374</int>
+ <int key="maxID">388</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1929,6 +1951,29 @@
</object>
</object>
<object class="IBPartialClassDescription">
+ <string key="className">GTMUILocalizer</string>
+ <string key="superclassName">NSObject</string>
+ <object class="NSMutableDictionary" key="outlets">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSMutableArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>otherObjectToLocalize_</string>
+ <string>owner_</string>
+ <string>yetAnotherObjectToLocalize_</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>id</string>
+ <string>id</string>
+ <string>id</string>
+ </object>
+ </object>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">AppKit/GTMUILocalizer.h</string>
+ </object>
+ </object>
+ <object class="IBPartialClassDescription">
<string key="className">NSApplication</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier" id="271775925">
<string key="majorKey">IBProjectSource</string>
diff --git a/UnitTesting/TestData/GTMUnitTestingTestApp.gtmUTState b/UnitTesting/TestData/GTMUnitTestingTestApp.gtmUTState
index 525535b..e7c7e05 100644
--- a/UnitTesting/TestData/GTMUnitTestingTestApp.gtmUTState
+++ b/UnitTesting/TestData/GTMUnitTestingTestApp.gtmUTState
@@ -1166,7 +1166,7 @@
<key>MenuItemTag</key>
<integer>0</integer>
<key>MenuItemTitle</key>
- <string>Show Fonts</string>
+ <string>¬Menu Item</string>
</dict>
<key>MenuItem 1</key>
<dict>
@@ -1188,12 +1188,12 @@
<string>Show Colors</string>
</dict>
<key>MenuTitle</key>
- <string>Format</string>
+ <string>¬Menu Title</string>
</dict>
<key>MenuItemTag</key>
<integer>0</integer>
<key>MenuItemTitle</key>
- <string>Format</string>
+ <string>¬Menu Title</string>
</dict>
<key>MenuItem 4</key>
<dict>
@@ -1411,6 +1411,26 @@
</dict>
<key>ViewSubView 11</key>
<dict>
+ <key>TabItem 0</key>
+ <dict>
+ <key>TabLabel</key>
+ <string>Tab</string>
+ <key>TabView</key>
+ <dict>
+ <key>ViewIsHidden</key>
+ <false/>
+ </dict>
+ </dict>
+ <key>TabItem 1</key>
+ <dict>
+ <key>TabLabel</key>
+ <string>View</string>
+ <key>TabView</key>
+ <dict>
+ <key>ViewIsHidden</key>
+ <false/>
+ </dict>
+ </dict>
<key>ViewIsHidden</key>
<false/>
<key>ViewSubView 0</key>
diff --git a/UnitTesting/TestData/GTMUnitTestingWindow.gtmUTState b/UnitTesting/TestData/GTMUnitTestingWindow.gtmUTState
index 27dd08e..17f77c8 100644
--- a/UnitTesting/TestData/GTMUnitTestingWindow.gtmUTState
+++ b/UnitTesting/TestData/GTMUnitTestingWindow.gtmUTState
@@ -112,6 +112,26 @@
</dict>
<key>ViewSubView 11</key>
<dict>
+ <key>TabItem 0</key>
+ <dict>
+ <key>TabLabel</key>
+ <string>Tab</string>
+ <key>TabView</key>
+ <dict>
+ <key>ViewIsHidden</key>
+ <false/>
+ </dict>
+ </dict>
+ <key>TabItem 1</key>
+ <dict>
+ <key>TabLabel</key>
+ <string>View</string>
+ <key>TabView</key>
+ <dict>
+ <key>ViewIsHidden</key>
+ <false/>
+ </dict>
+ </dict>
<key>ViewIsHidden</key>
<false/>
<key>ViewSubView 0</key>