OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/memory/scoped_nsobject.h" | 5 #include "base/memory/scoped_nsobject.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/prefs/public/pref_observer.h" | |
8 #include "base/string_util.h" | 7 #include "base/string_util.h" |
9 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 8 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
10 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 9 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
11 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
12 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 11 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
13 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
14 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
15 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
17 #import "third_party/ocmock/gtest_support.h" | 16 #import "third_party/ocmock/gtest_support.h" |
18 #import "third_party/ocmock/ocmock/OCMock.h" | 17 #import "third_party/ocmock/ocmock/OCMock.h" |
19 | 18 |
20 // A BrowserWindowCocoa that goes PONG when | 19 // A BrowserWindowCocoa that goes PONG when |
21 // BOOKMARK_BAR_VISIBILITY_PREF_CHANGED is sent. This is so we can be | 20 // BOOKMARK_BAR_VISIBILITY_PREF_CHANGED is sent. This is so we can be |
22 // sure we are observing it. | 21 // sure we are observing it. |
23 class BrowserWindowCocoaPong : public BrowserWindowCocoa, public PrefObserver { | 22 class BrowserWindowCocoaPong : public BrowserWindowCocoa { |
24 public: | 23 public: |
25 BrowserWindowCocoaPong(Browser* browser, | 24 BrowserWindowCocoaPong(Browser* browser, |
26 BrowserWindowController* controller) | 25 BrowserWindowController* controller) |
27 : BrowserWindowCocoa(browser, controller) { | 26 : BrowserWindowCocoa(browser, controller) { |
28 pong_ = false; | 27 pong_ = false; |
29 } | 28 } |
30 virtual ~BrowserWindowCocoaPong() { } | 29 virtual ~BrowserWindowCocoaPong() { } |
31 | 30 |
32 virtual void OnPreferenceChanged(PrefServiceBase* service, | 31 virtual void OnShowBookmarkBarChanged() OVERRIDE { |
33 const std::string& pref_name) OVERRIDE { | 32 pong_ = true; |
34 if (pref_name == prefs::kShowBookmarkBar) | |
35 pong_ = true; | |
36 } | 33 } |
37 | 34 |
38 bool pong_; | 35 bool pong_; |
39 }; | 36 }; |
40 | 37 |
41 // Main test class. | 38 // Main test class. |
42 class BrowserWindowCocoaTest : public CocoaProfileTest { | 39 class BrowserWindowCocoaTest : public CocoaProfileTest { |
43 virtual void SetUp() { | 40 virtual void SetUp() { |
44 CocoaProfileTest::SetUp(); | 41 CocoaProfileTest::SetUp(); |
45 ASSERT_TRUE(browser()); | 42 ASSERT_TRUE(browser()); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 [[[window_ stub] andReturn:nil] delegate]; | 234 [[[window_ stub] andReturn:nil] delegate]; |
238 [[[controller_ stub] andReturn:window_] window]; | 235 [[[controller_ stub] andReturn:window_] window]; |
239 [[window_ expect] orderOut:nil]; | 236 [[window_ expect] orderOut:nil]; |
240 [[window_ expect] close]; | 237 [[window_ expect] close]; |
241 CreateAndCloseBrowserWindow(); | 238 CreateAndCloseBrowserWindow(); |
242 EXPECT_OCMOCK_VERIFY(controller_); | 239 EXPECT_OCMOCK_VERIFY(controller_); |
243 EXPECT_OCMOCK_VERIFY(window_); | 240 EXPECT_OCMOCK_VERIFY(window_); |
244 } | 241 } |
245 | 242 |
246 // TODO(???): test other methods of BrowserWindowCocoa | 243 // TODO(???): test other methods of BrowserWindowCocoa |
OLD | NEW |