Commits

Anonymous committed ce6e1a9

Move stopUdating to -close instead of -dealloc

  • Participants
  • Parent commits 199c0df

Comments (0)

Files changed (2)

File WhereIsMyMac-WithUnitTests/Classes/WhereIsMyMacWindowController.m

 
 - (void)dealloc
 {
-	[_locationManager stopUpdatingLocation];
 	[_locationManager release];
 	[_locationFormatter release];
 	[_workspace release];
 	[super dealloc];
 }
 
+- (void)close
+{
+	[_locationManager stopUpdatingLocation];
+}
+
 - (void)windowDidLoad
 {
 	_locationManager.delegate = _locationFormatter;

File WhereIsMyMac-WithUnitTests/Classes/WhereIsMyMacWindowControllerTests.m

 
 @implementation WhereIsMyMacWindowControllerTests
 
+#pragma mark -
+#pragma mark Fixture
+
 - (void)setUp
 {
 	// Setup
 	[_mockWorkspace verify];
 	
 	// Teardown
-	[_windowController close];
 	[_windowController release]; _windowController = nil;
 }
 
+#pragma mark -
+#pragma mark Tests
+
 - (void)testOutletConnectionsAfterLoadWindow
 {
-	// Setup
-	[[_mockLocationManager stub] stopUpdatingLocation];
-
 	// Execute
 	[_windowController loadWindow];
 
 	// Setup
 	[[_mockLocationManager expect] setDelegate:_mockLocationFormatter];
 	[[_mockLocationManager expect] startUpdatingLocation];
-	[[_mockLocationManager stub] stopUpdatingLocation];
 
 	// Execute
 	[_windowController windowDidLoad];
 - (void)testOpenInDefaultBrowserActionOpensGoogleMapsUrlInWorkspace
 {
 	// Setup
-	[[_mockLocationManager stub] stopUpdatingLocation];
 	[[[_mockLocationManager stub] andReturn:nil] location];
 	NSURL * dummyUrl = [NSURL URLWithString:@"http://example.com/"];
 	[[[_mockLocationFormatter stub] andReturn:dummyUrl] googleMapsUrlForLocation:nil];
 	[_windowController openInDefaultBrowser:nil];
 }
 
-- (void)testDeallocStopsLocationManager
+- (void)testCloseStopsLocationManager
 {
 	// Setup
-	NSUInteger preRetainCount = [_mockLocationManager retainCount];
 	[[_mockLocationManager expect] stopUpdatingLocation];
 
 	// Execute
-	[_windowController release];
-	_windowController = nil;
-
-	// Verify
-	NSUInteger postRetainCount = [_mockLocationManager retainCount];
-	STAssertEquals(postRetainCount, preRetainCount - 1, nil);
+	[_windowController close];
 }
 
 @end