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

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

Issue 402066: Moved a whole pile of unittests over to CocoaTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | Annotate | Revision Log
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"
(...skipping 23 matching lines...) Expand all
34 class PrefsControllerTest : public CocoaTest { 34 class PrefsControllerTest : public CocoaTest {
35 public: 35 public:
36 virtual void SetUp() { 36 virtual void SetUp() {
37 CocoaTest::SetUp(); 37 CocoaTest::SetUp();
38 // The metrics reporting pref is registerd on the local state object in 38 // The metrics reporting pref is registerd on the local state object in
39 // real builds, but we don't have one of those for unit tests. Register 39 // real builds, but we don't have one of those for unit tests. Register
40 // it on prefs so we'll find it when we go looking. 40 // it on prefs so we'll find it when we go looking.
41 PrefService* prefs = browser_helper_.profile()->GetPrefs(); 41 PrefService* prefs = browser_helper_.profile()->GetPrefs();
42 prefs->RegisterBooleanPref(prefs::kMetricsReportingEnabled, false); 42 prefs->RegisterBooleanPref(prefs::kMetricsReportingEnabled, false);
43 43
44 pref_controller_.reset([[PreferencesWindowController alloc] 44 pref_controller_ = [[PreferencesWindowController alloc]
45 initWithProfile:browser_helper_.profile() 45 initWithProfile:browser_helper_.profile()
46 initialPage:OPTIONS_PAGE_DEFAULT]); 46 initialPage:OPTIONS_PAGE_DEFAULT];
47 EXPECT_TRUE(pref_controller_.get()); 47 EXPECT_TRUE(pref_controller_);
48 } 48 }
49 49
50 virtual void TearDown() { 50 virtual void TearDown() {
51 pref_controller_.reset(NULL); 51 [pref_controller_ close];
52 CocoaTest::TearDown(); 52 CocoaTest::TearDown();
53 } 53 }
54 54
55 BrowserTestHelper browser_helper_; 55 BrowserTestHelper browser_helper_;
56 scoped_nsobject<PreferencesWindowController> pref_controller_; 56 PreferencesWindowController* pref_controller_;
57 }; 57 };
58 58
59 // Test showing the preferences window and making sure it's visible, then 59 // Test showing the preferences window and making sure it's visible, then
60 // making sure we get the notification when it's closed. 60 // making sure we get the notification when it's closed.
61 TEST_F(PrefsControllerTest, ShowAndClose) { 61 TEST_F(PrefsControllerTest, ShowAndClose) {
62 [pref_controller_ showPreferences:nil]; 62 [pref_controller_ showPreferences:nil];
63 EXPECT_TRUE([[pref_controller_ window] isVisible]); 63 EXPECT_TRUE([[pref_controller_ window] isVisible]);
64 64
65 scoped_nsobject<PrefsClosedObserver> observer( 65 scoped_nsobject<PrefsClosedObserver> observer(
66 [[PrefsClosedObserver alloc] init]); 66 [[PrefsClosedObserver alloc] init]);
67 [[NSNotificationCenter defaultCenter] 67 NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
68 addObserver:observer.get() 68 [defaultCenter addObserver:observer.get()
69 selector:@selector(prefsWindowClosed:) 69 selector:@selector(prefsWindowClosed:)
70 name:kUserDoneEditingPrefsNotification 70 name:NSWindowWillCloseNotification
71 object:pref_controller_.get()]; 71 object:[pref_controller_ window]];
72 [[pref_controller_ window] performClose:observer]; 72 [[pref_controller_ window] performClose:observer];
73 EXPECT_TRUE(observer.get()->gotNotification_); 73 EXPECT_TRUE(observer.get()->gotNotification_);
74 [[NSNotificationCenter defaultCenter] removeObserver:observer.get()]; 74 [defaultCenter removeObserver:observer.get()];
75 pref_controller_ = nil;
75 } 76 }
76 77
77 TEST_F(PrefsControllerTest, ValidateCustomHomePagesTable) { 78 TEST_F(PrefsControllerTest, ValidateCustomHomePagesTable) {
78 // First, insert two valid URLs into the CustomHomePagesModel. 79 // First, insert two valid URLs into the CustomHomePagesModel.
79 GURL url1("http://www.google.com/"); 80 GURL url1("http://www.google.com/");
80 GURL url2("http://maps.google.com/"); 81 GURL url2("http://maps.google.com/");
81 std::vector<GURL> urls; 82 std::vector<GURL> urls;
82 urls.push_back(url1); 83 urls.push_back(url1);
83 urls.push_back(url2); 84 urls.push_back(url2);
84 [[pref_controller_ customPagesSource] setURLs:urls]; 85 [[pref_controller_ customPagesSource] setURLs:urls];
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 231
231 // 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
232 // to stick around until the animation finishes. 233 // to stick around until the animation finishes.
233 } 234 }
234 235
235 // TODO(akalin): Figure out how to test sync controls. 236 // TODO(akalin): Figure out how to test sync controls.
236 // 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
237 // when there isn't a sync service. 238 // when there isn't a sync service.
238 239
239 } // namespace 240 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/preferences_window_controller.mm ('k') | chrome/browser/cocoa/styled_text_field_cell_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698