aboutsummaryrefslogtreecommitdiff
path: root/AppKit/GTMLoginItemsTest.m
diff options
context:
space:
mode:
authorGravatar dmaclach <dmaclach@google.com>2016-10-07 12:10:23 -0400
committerGravatar Thomas Van Lenten <thomasvl@google.com>2016-10-07 12:21:06 -0400
commit42124b3691197c3c4f52f069775fa0390a8ff942 (patch)
treeebd373d398ea64b45bdc1d196fa0a2c5f57cabfd /AppKit/GTMLoginItemsTest.m
parent57eeab4193210df8ab0c81e9d3f1ee1ad3e24492 (diff)
First cut at pruning things/updating things.
Remove a bunch of code that Google stopped using/maintaining rather than trying to update it it. Some would be hard to update, some actually has system provided replacements; others are patterns that just don't seem as common now. Prune out the code related to macOS <= 10.5, start pruning some of the really old iOS support also. Get the projects mostly limping again with modern Xcodes so tests can be run. If someone ends up on this commit via history for something they still find as useful, feel free to do a pull request to bring the snippet of code back to life and update it for current SDKs.
Diffstat (limited to 'AppKit/GTMLoginItemsTest.m')
-rw-r--r--AppKit/GTMLoginItemsTest.m93
1 files changed, 47 insertions, 46 deletions
diff --git a/AppKit/GTMLoginItemsTest.m b/AppKit/GTMLoginItemsTest.m
index 50b7482..3784edb 100644
--- a/AppKit/GTMLoginItemsTest.m
+++ b/AppKit/GTMLoginItemsTest.m
@@ -6,9 +6,9 @@
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -16,7 +16,6 @@
// the License.
//
-#import <SenTestingKit/SenTestingKit.h>
#import "GTMSenTestCase.h"
#import "GTMLoginItems.h"
@@ -31,7 +30,7 @@
static BOOL ItemsListHasPath(NSArray *items, NSString *path) {
NSDictionary *item = nil;
- GTM_FOREACH_OBJECT(item, items) {
+ for (item in items) {
NSString *itemPath = [item objectForKey:kGTMLoginItemsPathKey];
if (itemPath && [itemPath isEqual:path]) {
return YES;
@@ -47,89 +46,91 @@ static BOOL ItemsListHasPath(NSArray *items, NSString *path) {
NSError *error = nil;
NSString *bogusAppPath = @"/Applications/AppThatDoesNotExist.app";
NSString *bogusAppName = @"AppThatDoesNotExist";
-
+
// fetch the starting values
NSArray *initialItems = [GTMLoginItems loginItems:&error];
- STAssertNotNil(initialItems, @"shouldn't be nil (%@)", error);
- STAssertFalse(ItemsListHasPath(initialItems, bogusAppPath),
- @"bogusApp shouldn't be in list to start for test (%@)", initialItems);
-
+ XCTAssertNotNil(initialItems, @"shouldn't be nil (%@)", error);
+ XCTAssertFalse(ItemsListHasPath(initialItems, bogusAppPath),
+ @"bogusApp shouldn't be in list to start for test (%@)",
+ initialItems);
+
// check by path
- STAssertFalse([GTMLoginItems pathInLoginItems:bogusAppPath], nil);
-
+ XCTAssertFalse([GTMLoginItems pathInLoginItems:bogusAppPath]);
+
// check by name
- STAssertFalse([GTMLoginItems itemWithNameInLoginItems:bogusAppName], nil);
-
+ XCTAssertFalse([GTMLoginItems itemWithNameInLoginItems:bogusAppName]);
+
// remove it by path
[GTMLoginItems removePathFromLoginItems:bogusAppPath];
NSArray *curItems = [GTMLoginItems loginItems:nil];
- STAssertEqualObjects(initialItems, curItems, nil);
-
+ XCTAssertEqualObjects(initialItems, curItems);
+
// remove it by name
[GTMLoginItems removeItemWithNameFromLoginItems:bogusAppName];
curItems = [GTMLoginItems loginItems:nil];
- STAssertEqualObjects(initialItems, curItems, nil);
+ XCTAssertEqualObjects(initialItems, curItems);
}
- (void)testModification {
#if MODIFICATION_TESTS_ENABLED
-
+
NSError *error = nil;
NSString *textEditPath = @"/Applications/TextEdit.app";
NSString *textEditName = @"TextEdit";
-
+
// fetch the starting values
NSArray *initialItems = [GTMLoginItems loginItems:&error];
- STAssertNotNil(initialItems, @"shouldn't be nil (%@)", error);
- STAssertFalse(ItemsListHasPath(initialItems, textEditPath),
- @"textedit shouldn't be in list to start for test (%@)", initialItems);
-
+ XCTAssertNotNil(initialItems, @"shouldn't be nil (%@)", error);
+ XCTAssertFalse(ItemsListHasPath(initialItems, textEditPath),
+ @"textedit shouldn't be in list to start for test (%@)",
+ initialItems);
+
// add textedit
[GTMLoginItems addPathToLoginItems:textEditPath hide:NO];
NSArray *curItems = [GTMLoginItems loginItems:nil];
- STAssertNotEqualObjects(initialItems, curItems, nil);
-
+ XCTAssertNotEqualObjects(initialItems, curItems);
+
// check by path
- STAssertTrue([GTMLoginItems pathInLoginItems:textEditPath], nil);
-
+ XCTAssertTrue([GTMLoginItems pathInLoginItems:textEditPath]);
+
// check by name
- STAssertTrue([GTMLoginItems itemWithNameInLoginItems:textEditName], nil);
-
+ XCTAssertTrue([GTMLoginItems itemWithNameInLoginItems:textEditName]);
+
// remove it by path
[GTMLoginItems removePathFromLoginItems:textEditPath];
curItems = [GTMLoginItems loginItems:nil];
- STAssertEqualObjects(initialItems, curItems, nil);
-
+ STAssertEqualObjects(initialItems, curItems);
+
// check by path
- STAssertFalse([GTMLoginItems pathInLoginItems:textEditPath], nil);
-
+ XCTAssertFalse([GTMLoginItems pathInLoginItems:textEditPath]);
+
// check by name
- STAssertFalse([GTMLoginItems itemWithNameInLoginItems:textEditName], nil);
-
+ XCTAssertFalse([GTMLoginItems itemWithNameInLoginItems:textEditName]);
+
// add textedit
[GTMLoginItems addPathToLoginItems:textEditPath hide:NO];
curItems = [GTMLoginItems loginItems:nil];
- STAssertNotEqualObjects(initialItems, curItems, nil);
-
+ STAssertNotEqualObjects(initialItems, curItems);
+
// check by path
- STAssertTrue([GTMLoginItems pathInLoginItems:textEditPath], nil);
-
+ XCTAssertTrue([GTMLoginItems pathInLoginItems:textEditPath]);
+
// check by name
- STAssertTrue([GTMLoginItems itemWithNameInLoginItems:textEditName], nil);
-
+ XCTAssertTrue([GTMLoginItems itemWithNameInLoginItems:textEditName]);
+
// remove it by name
[GTMLoginItems removeItemWithNameFromLoginItems:textEditName];
curItems = [GTMLoginItems loginItems:nil];
- STAssertEqualObjects(initialItems, curItems, nil);
-
+ XCTAssertEqualObjects(initialItems, curItems);
+
// check by path
- STAssertFalse([GTMLoginItems pathInLoginItems:textEditPath], nil);
-
+ XCTAssertFalse([GTMLoginItems pathInLoginItems:textEditPath]);
+
// check by name
- STAssertFalse([GTMLoginItems itemWithNameInLoginItems:textEditName], nil);
-
+ XCTAssertFalse([GTMLoginItems itemWithNameInLoginItems:textEditName]);
+
#endif // MODIFICATION_TESTS_ENABLED
}