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

Side by Side Diff: chrome/browser/cocoa/preferences_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/preferences_window_controller.h" 8 #import "chrome/browser/cocoa/preferences_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/custom_home_pages_model.h" 11 #import "chrome/browser/cocoa/custom_home_pages_model.h"
12 #include "chrome/browser/options_window.h" 12 #include "chrome/browser/options_window.h"
13 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #import "testing/gtest_mac.h"
15 #include "testing/platform_test.h" 16 #include "testing/platform_test.h"
16 17
17 // Helper Objective-C object that sets a BOOL when we get a particular 18 // Helper Objective-C object that sets a BOOL when we get a particular
18 // callback from the prefs window. 19 // callback from the prefs window.
19 @interface PrefsClosedObserver : NSObject { 20 @interface PrefsClosedObserver : NSObject {
20 @public 21 @public
21 BOOL gotNotification_; 22 BOOL gotNotification_;
22 } 23 }
23 - (void)prefsWindowClosed:(NSNotification*)notify; 24 - (void)prefsWindowClosed:(NSNotification*)notify;
24 @end 25 @end
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 NSString* personalStuffIdentifier = [personalStuffToolbarItem itemIdentifier]; 191 NSString* personalStuffIdentifier = [personalStuffToolbarItem itemIdentifier];
191 NSString* underTheHoodIdentifier = [underTheHoodToolbarItem itemIdentifier]; 192 NSString* underTheHoodIdentifier = [underTheHoodToolbarItem itemIdentifier];
192 IntegerPrefMember* lastSelectedPage = [pref_controller_ lastSelectedPage]; 193 IntegerPrefMember* lastSelectedPage = [pref_controller_ lastSelectedPage];
193 194
194 // Test without animation. 195 // Test without animation.
195 196
196 [pref_controller_ switchToPage:OPTIONS_PAGE_GENERAL animate:NO]; 197 [pref_controller_ switchToPage:OPTIONS_PAGE_GENERAL animate:NO];
197 EXPECT_TRUE([basicsView isDescendantOf:contentView]); 198 EXPECT_TRUE([basicsView isDescendantOf:contentView]);
198 EXPECT_FALSE([personalStuffView isDescendantOf:contentView]); 199 EXPECT_FALSE([personalStuffView isDescendantOf:contentView]);
199 EXPECT_FALSE([underTheHoodView isDescendantOf:contentView]); 200 EXPECT_FALSE([underTheHoodView isDescendantOf:contentView]);
200 EXPECT_TRUE([[toolbar selectedItemIdentifier] isEqualTo:basicsIdentifier]); 201 EXPECT_NSEQ(basicsIdentifier, [toolbar selectedItemIdentifier]);
201 EXPECT_EQ(OPTIONS_PAGE_GENERAL, lastSelectedPage->GetValue()); 202 EXPECT_EQ(OPTIONS_PAGE_GENERAL, lastSelectedPage->GetValue());
202 EXPECT_TRUE([[window title] isEqualTo:[basicsToolbarItem label]]); 203 EXPECT_NSEQ([window title], [basicsToolbarItem label]);
Mark Mentovai 2010/08/06 20:01:01 Reverse? Also on 211, 219, and 230.
203 204
204 [pref_controller_ switchToPage:OPTIONS_PAGE_CONTENT animate:NO]; 205 [pref_controller_ switchToPage:OPTIONS_PAGE_CONTENT animate:NO];
205 EXPECT_FALSE([basicsView isDescendantOf:contentView]); 206 EXPECT_FALSE([basicsView isDescendantOf:contentView]);
206 EXPECT_TRUE([personalStuffView isDescendantOf:contentView]); 207 EXPECT_TRUE([personalStuffView isDescendantOf:contentView]);
207 EXPECT_FALSE([underTheHoodView isDescendantOf:contentView]); 208 EXPECT_FALSE([underTheHoodView isDescendantOf:contentView]);
208 EXPECT_TRUE([[toolbar selectedItemIdentifier] 209 EXPECT_NSEQ([toolbar selectedItemIdentifier], personalStuffIdentifier);
209 isEqualTo:personalStuffIdentifier]);
210 EXPECT_EQ(OPTIONS_PAGE_CONTENT, lastSelectedPage->GetValue()); 210 EXPECT_EQ(OPTIONS_PAGE_CONTENT, lastSelectedPage->GetValue());
211 EXPECT_TRUE([[window title] isEqualTo:[personalStuffToolbarItem label]]); 211 EXPECT_NSEQ([window title], [personalStuffToolbarItem label]);
212 212
213 [pref_controller_ switchToPage:OPTIONS_PAGE_ADVANCED animate:NO]; 213 [pref_controller_ switchToPage:OPTIONS_PAGE_ADVANCED animate:NO];
214 EXPECT_FALSE([basicsView isDescendantOf:contentView]); 214 EXPECT_FALSE([basicsView isDescendantOf:contentView]);
215 EXPECT_FALSE([personalStuffView isDescendantOf:contentView]); 215 EXPECT_FALSE([personalStuffView isDescendantOf:contentView]);
216 EXPECT_TRUE([underTheHoodView isDescendantOf:contentView]); 216 EXPECT_TRUE([underTheHoodView isDescendantOf:contentView]);
217 EXPECT_TRUE([[toolbar selectedItemIdentifier] 217 EXPECT_NSEQ([toolbar selectedItemIdentifier], underTheHoodIdentifier);
218 isEqualTo:underTheHoodIdentifier]);
219 EXPECT_EQ(OPTIONS_PAGE_ADVANCED, lastSelectedPage->GetValue()); 218 EXPECT_EQ(OPTIONS_PAGE_ADVANCED, lastSelectedPage->GetValue());
220 EXPECT_TRUE([[window title] isEqualTo:[underTheHoodToolbarItem label]]); 219 EXPECT_NSEQ([window title], [underTheHoodToolbarItem label]);
221 220
222 // Test OPTIONS_PAGE_DEFAULT. 221 // Test OPTIONS_PAGE_DEFAULT.
223 222
224 lastSelectedPage->SetValue(OPTIONS_PAGE_CONTENT); 223 lastSelectedPage->SetValue(OPTIONS_PAGE_CONTENT);
225 [pref_controller_ switchToPage:OPTIONS_PAGE_DEFAULT animate:NO]; 224 [pref_controller_ switchToPage:OPTIONS_PAGE_DEFAULT animate:NO];
226 EXPECT_FALSE([basicsView isDescendantOf:contentView]); 225 EXPECT_FALSE([basicsView isDescendantOf:contentView]);
227 EXPECT_TRUE([personalStuffView isDescendantOf:contentView]); 226 EXPECT_TRUE([personalStuffView isDescendantOf:contentView]);
228 EXPECT_FALSE([underTheHoodView isDescendantOf:contentView]); 227 EXPECT_FALSE([underTheHoodView isDescendantOf:contentView]);
229 EXPECT_TRUE([[toolbar selectedItemIdentifier] 228 EXPECT_NSEQ(personalStuffIdentifier, [toolbar selectedItemIdentifier]);
230 isEqualTo:personalStuffIdentifier]);
231 EXPECT_EQ(OPTIONS_PAGE_CONTENT, lastSelectedPage->GetValue()); 229 EXPECT_EQ(OPTIONS_PAGE_CONTENT, lastSelectedPage->GetValue());
232 EXPECT_TRUE([[window title] isEqualTo:[personalStuffToolbarItem label]]); 230 EXPECT_NSEQ([window title], [personalStuffToolbarItem label]);
233 231
234 // TODO(akalin): Figure out how to test animation; we'll need everything 232 // TODO(akalin): Figure out how to test animation; we'll need everything
235 // to stick around until the animation finishes. 233 // to stick around until the animation finishes.
236 } 234 }
237 235
238 // TODO(akalin): Figure out how to test sync controls. 236 // TODO(akalin): Figure out how to test sync controls.
239 // TODO(akalin): Figure out how to test that sync controls are not shown 237 // TODO(akalin): Figure out how to test that sync controls are not shown
240 // when there isn't a sync service. 238 // when there isn't a sync service.
241 239
242 } // namespace 240 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698