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/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/bookmarks/bookmark_utils.h" | 8 #include "chrome/browser/bookmarks/bookmark_utils.h" |
9 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 9 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
10 #include "chrome/browser/ui/cocoa/browser_window_controller.h" | 10 #include "chrome/browser/ui/cocoa/browser_window_controller.h" |
11 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 11 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
12 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
| 13 #include "chrome/common/pref_names.h" |
| 14 #include "content/common/notification_details.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 | 16 |
15 // A BrowserWindowCocoa that goes PONG when | 17 // A BrowserWindowCocoa that goes PONG when |
16 // BOOKMARK_BAR_VISIBILITY_PREF_CHANGED is sent. This is so we can be | 18 // BOOKMARK_BAR_VISIBILITY_PREF_CHANGED is sent. This is so we can be |
17 // sure we are observing it. | 19 // sure we are observing it. |
18 class BrowserWindowCocoaPong : public BrowserWindowCocoa { | 20 class BrowserWindowCocoaPong : public BrowserWindowCocoa { |
19 public: | 21 public: |
20 BrowserWindowCocoaPong(Browser* browser, | 22 BrowserWindowCocoaPong(Browser* browser, |
21 BrowserWindowController* controller) | 23 BrowserWindowController* controller) |
22 : BrowserWindowCocoa(browser, controller) { | 24 : BrowserWindowCocoa(browser, controller) { |
23 pong_ = false; | 25 pong_ = false; |
24 } | 26 } |
25 virtual ~BrowserWindowCocoaPong() { } | 27 virtual ~BrowserWindowCocoaPong() { } |
26 | 28 |
27 void Observe(int type, | 29 void Observe(int type, |
28 const NotificationSource& source, | 30 const NotificationSource& source, |
29 const NotificationDetails& details) { | 31 const NotificationDetails& details) { |
30 if (type == chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED) | 32 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
31 pong_ = true; | 33 const std::string& pref_name = *Details<std::string>(details).ptr(); |
| 34 if (pref_name == prefs::kShowBookmarkBar) |
| 35 pong_ = true; |
| 36 } |
32 BrowserWindowCocoa::Observe(type, source, details); | 37 BrowserWindowCocoa::Observe(type, source, details); |
33 } | 38 } |
34 | 39 |
35 bool pong_; | 40 bool pong_; |
36 }; | 41 }; |
37 | 42 |
38 // Main test class. | 43 // Main test class. |
39 class BrowserWindowCocoaTest : public CocoaProfileTest { | 44 class BrowserWindowCocoaTest : public CocoaProfileTest { |
40 virtual void SetUp() { | 45 virtual void SetUp() { |
41 CocoaProfileTest::SetUp(); | 46 CocoaProfileTest::SetUp(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 | 115 |
111 EXPECT_FALSE(bwc->IsFullscreen()); | 116 EXPECT_FALSE(bwc->IsFullscreen()); |
112 bwc->SetFullscreen(true); | 117 bwc->SetFullscreen(true); |
113 EXPECT_TRUE(bwc->IsFullscreen()); | 118 EXPECT_TRUE(bwc->IsFullscreen()); |
114 bwc->SetFullscreen(false); | 119 bwc->SetFullscreen(false); |
115 EXPECT_FALSE(bwc->IsFullscreen()); | 120 EXPECT_FALSE(bwc->IsFullscreen()); |
116 [fake_controller close]; | 121 [fake_controller close]; |
117 } | 122 } |
118 | 123 |
119 // TODO(???): test other methods of BrowserWindowCocoa | 124 // TODO(???): test other methods of BrowserWindowCocoa |
OLD | NEW |