Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(678)

Side by Side Diff: chrome/browser/cocoa/about_window_controller_unittest.mm

Issue 3095004: [Mac] Use the new {EXPECT,ASSERT}_NS{EQ,NE} macros where possible. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Fix compile Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "base/scoped_nsobject.h" 7 #import "base/scoped_nsobject.h"
8 #import "chrome/browser/cocoa/about_window_controller.h" 8 #import "chrome/browser/cocoa/about_window_controller.h"
9 #include "chrome/browser/cocoa/browser_test_helper.h" 9 #include "chrome/browser/cocoa/browser_test_helper.h"
10 #include "chrome/browser/cocoa/cocoa_test_helper.h" 10 #include "chrome/browser/cocoa/cocoa_test_helper.h"
11 #import "chrome/browser/cocoa/keystone_glue.h" 11 #import "chrome/browser/cocoa/keystone_glue.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #import "testing/gtest_mac.h"
13 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
14 15
15 namespace { 16 namespace {
16 17
17 void PostAutoupdateStatusNotification(AutoupdateStatus status, 18 void PostAutoupdateStatusNotification(AutoupdateStatus status,
18 NSString* version) { 19 NSString* version) {
19 NSNumber* statusNumber = [NSNumber numberWithInt:status]; 20 NSNumber* statusNumber = [NSNumber numberWithInt:status];
20 NSMutableDictionary* dictionary = 21 NSMutableDictionary* dictionary =
21 [NSMutableDictionary dictionaryWithObjects:&statusNumber 22 [NSMutableDictionary dictionaryWithObjects:&statusNumber
22 forKeys:&kAutoupdateStatusStatus 23 forKeys:&kAutoupdateStatusStatus
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // Make sure the button is hooked up 89 // Make sure the button is hooked up
89 ASSERT_EQ([button target], about_window_controller_); 90 ASSERT_EQ([button target], about_window_controller_);
90 ASSERT_EQ([button action], @selector(updateNow:)); 91 ASSERT_EQ([button action], @selector(updateNow:));
91 } 92 }
92 93
93 // Doesn't confirm correctness, but does confirm something happens. 94 // Doesn't confirm correctness, but does confirm something happens.
94 TEST_F(AboutWindowControllerTest, TestCallbacks) { 95 TEST_F(AboutWindowControllerTest, TestCallbacks) {
95 NSString *lastText = [[about_window_controller_ updateText] 96 NSString *lastText = [[about_window_controller_ updateText]
96 stringValue]; 97 stringValue];
97 PostAutoupdateStatusNotification(kAutoupdateCurrent, @"foo"); 98 PostAutoupdateStatusNotification(kAutoupdateCurrent, @"foo");
98 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] 99 ASSERT_NSNE(lastText, [[about_window_controller_ updateText] stringValue]);
99 stringValue]]);
100 100
101 lastText = [[about_window_controller_ updateText] stringValue]; 101 lastText = [[about_window_controller_ updateText] stringValue];
102 PostAutoupdateStatusNotification(kAutoupdateCurrent, @"foo"); 102 PostAutoupdateStatusNotification(kAutoupdateCurrent, @"foo");
103 ASSERT_TRUE([lastText isEqual:[[about_window_controller_ updateText] 103 ASSERT_NSEQ(lastText, [[about_window_controller_ updateText] stringValue]);
104 stringValue]]);
105 104
106 lastText = [[about_window_controller_ updateText] stringValue]; 105 lastText = [[about_window_controller_ updateText] stringValue];
107 PostAutoupdateStatusNotification(kAutoupdateCurrent, @"bar"); 106 PostAutoupdateStatusNotification(kAutoupdateCurrent, @"bar");
108 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] 107 ASSERT_NSNE(lastText, [[about_window_controller_ updateText] stringValue]);
109 stringValue]]);
110 108
111 lastText = [[about_window_controller_ updateText] stringValue]; 109 lastText = [[about_window_controller_ updateText] stringValue];
112 PostAutoupdateStatusNotification(kAutoupdateAvailable, nil); 110 PostAutoupdateStatusNotification(kAutoupdateAvailable, nil);
113 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] 111 ASSERT_NSNE(lastText, [[about_window_controller_ updateText] stringValue]);
114 stringValue]]);
115 112
116 lastText = [[about_window_controller_ updateText] stringValue]; 113 lastText = [[about_window_controller_ updateText] stringValue];
117 PostAutoupdateStatusNotification(kAutoupdateCheckFailed, nil); 114 PostAutoupdateStatusNotification(kAutoupdateCheckFailed, nil);
118 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] 115 ASSERT_NSNE(lastText, [[about_window_controller_ updateText] stringValue]);
119 stringValue]]);
120 116
121 #if 0 117 #if 0
122 // TODO(mark): The kAutoupdateInstalled portion of the test is disabled 118 // TODO(mark): The kAutoupdateInstalled portion of the test is disabled
123 // because it leaks restart dialogs. If the About box is revised to use 119 // because it leaks restart dialogs. If the About box is revised to use
124 // a button within the box to advise a restart instead of popping dialogs, 120 // a button within the box to advise a restart instead of popping dialogs,
125 // these tests should be enabled. 121 // these tests should be enabled.
126 122
127 lastText = [[about_window_controller_ updateText] stringValue]; 123 lastText = [[about_window_controller_ updateText] stringValue];
128 PostAutoupdateStatusNotification(kAutoupdateInstalled, @"ver"); 124 PostAutoupdateStatusNotification(kAutoupdateInstalled, @"ver");
129 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] 125 ASSERT_NSNE(lastText, [[about_window_controller_ updateText] stringValue]);
130 stringValue]]);
131 126
132 lastText = [[about_window_controller_ updateText] stringValue]; 127 lastText = [[about_window_controller_ updateText] stringValue];
133 PostAutoupdateStatusNotification(kAutoupdateInstalled, nil); 128 PostAutoupdateStatusNotification(kAutoupdateInstalled, nil);
134 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ updateText] 129 ASSERT_NSNE(lastText, [[about_window_controller_ updateText] stringValue]);
135 stringValue]]);
136 #endif 130 #endif
137 131
138 lastText = [[about_window_controller_ updateText] stringValue]; 132 lastText = [[about_window_controller_ updateText] stringValue];
139 PostAutoupdateStatusNotification(kAutoupdateInstallFailed, nil); 133 PostAutoupdateStatusNotification(kAutoupdateInstallFailed, nil);
140 ASSERT_FALSE([lastText isEqual:[[about_window_controller_ 134 ASSERT_NSNE(lastText, [[about_window_controller_ updateText] stringValue]);
141 updateText] stringValue]]);
142 } 135 }
143 136
144 } // namespace 137 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698