OLD | NEW |
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 14 matching lines...) Expand all Loading... |
25 - (void)prefsWindowClosed:(NSNotification*)notify { | 25 - (void)prefsWindowClosed:(NSNotification*)notify { |
26 gotNotification_ = YES; | 26 gotNotification_ = YES; |
27 } | 27 } |
28 @end | 28 @end |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 class PrefsControllerTest : public PlatformTest { | 32 class PrefsControllerTest : public PlatformTest { |
33 public: | 33 public: |
34 PrefsControllerTest() { | 34 PrefsControllerTest() { |
35 // Since this is a platform-specific preference, it's not registered by | |
36 // any of the shared code. We have to register it ourselves. | |
37 PrefService* prefs = browser_helper_.profile()->GetPrefs(); | |
38 prefs->RegisterBooleanPref(prefs::kShowPageOptionsButtons, false); | |
39 // The metrics reporting pref is registerd on the local state object in | 35 // The metrics reporting pref is registerd on the local state object in |
40 // real builds, but we don't have one of those for unit tests. Register | 36 // real builds, but we don't have one of those for unit tests. Register |
41 // it on prefs so we'll find it when we go looking. | 37 // it on prefs so we'll find it when we go looking. |
| 38 PrefService* prefs = browser_helper_.profile()->GetPrefs(); |
42 prefs->RegisterBooleanPref(prefs::kMetricsReportingEnabled, false); | 39 prefs->RegisterBooleanPref(prefs::kMetricsReportingEnabled, false); |
43 | 40 |
44 pref_controller_.reset([[PreferencesWindowController alloc] | 41 pref_controller_.reset([[PreferencesWindowController alloc] |
45 initWithProfile:browser_helper_.profile()]); | 42 initWithProfile:browser_helper_.profile()]); |
46 EXPECT_TRUE(pref_controller_.get()); | 43 EXPECT_TRUE(pref_controller_.get()); |
47 } | 44 } |
48 | 45 |
49 BrowserTestHelper browser_helper_; | 46 BrowserTestHelper browser_helper_; |
50 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... | 47 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... |
51 scoped_nsobject<PreferencesWindowController> pref_controller_; | 48 scoped_nsobject<PreferencesWindowController> pref_controller_; |
(...skipping 14 matching lines...) Expand all Loading... |
66 selector:@selector(prefsWindowClosed:) | 63 selector:@selector(prefsWindowClosed:) |
67 name:kUserDoneEditingPrefsNotification | 64 name:kUserDoneEditingPrefsNotification |
68 object:pref_controller_.get()]; | 65 object:pref_controller_.get()]; |
69 [[pref_controller_ window] performClose:observer]; | 66 [[pref_controller_ window] performClose:observer]; |
70 EXPECT_TRUE(observer.get()->gotNotification_); | 67 EXPECT_TRUE(observer.get()->gotNotification_); |
71 [[NSNotificationCenter defaultCenter] removeObserver:observer.get()]; | 68 [[NSNotificationCenter defaultCenter] removeObserver:observer.get()]; |
72 #endif | 69 #endif |
73 } | 70 } |
74 | 71 |
75 } // namespace | 72 } // namespace |
OLD | NEW |