OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include "chrome/browser/ui/browser_commands.h" | 7 #include "chrome/browser/ui/browser_commands.h" |
8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
9 #include "chrome/test/base/browser_with_test_window_test.h" | 9 #include "chrome/test/base/browser_with_test_window_test.h" |
10 #include "content/public/browser/site_instance.h" | 10 #include "content/public/browser/site_instance.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 BrowserBookmarkBarTest() {} | 71 BrowserBookmarkBarTest() {} |
72 virtual ~BrowserBookmarkBarTest() {} | 72 virtual ~BrowserBookmarkBarTest() {} |
73 | 73 |
74 protected: | 74 protected: |
75 BookmarkBar::State window_bookmark_bar_state() const { | 75 BookmarkBar::State window_bookmark_bar_state() const { |
76 return static_cast<BookmarkBarStateTestBrowserWindow*>( | 76 return static_cast<BookmarkBarStateTestBrowserWindow*>( |
77 browser()->window())->bookmark_bar_state(); | 77 browser()->window())->bookmark_bar_state(); |
78 } | 78 } |
79 | 79 |
80 // BrowserWithTestWindowTest: | 80 // BrowserWithTestWindowTest: |
81 virtual void SetUp() OVERRIDE { | 81 virtual void SetUp() override { |
82 BrowserWithTestWindowTest::SetUp(); | 82 BrowserWithTestWindowTest::SetUp(); |
83 static_cast<BookmarkBarStateTestBrowserWindow*>( | 83 static_cast<BookmarkBarStateTestBrowserWindow*>( |
84 browser()->window())->set_browser(browser()); | 84 browser()->window())->set_browser(browser()); |
85 } | 85 } |
86 | 86 |
87 virtual BrowserWindow* CreateBrowserWindow() OVERRIDE { | 87 virtual BrowserWindow* CreateBrowserWindow() override { |
88 return new BookmarkBarStateTestBrowserWindow(); | 88 return new BookmarkBarStateTestBrowserWindow(); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 class BookmarkBarStateTestBrowserWindow : public TestBrowserWindow { | 92 class BookmarkBarStateTestBrowserWindow : public TestBrowserWindow { |
93 public: | 93 public: |
94 BookmarkBarStateTestBrowserWindow() | 94 BookmarkBarStateTestBrowserWindow() |
95 : browser_(NULL), | 95 : browser_(NULL), |
96 bookmark_bar_state_(BookmarkBar::HIDDEN) {} | 96 bookmark_bar_state_(BookmarkBar::HIDDEN) {} |
97 virtual ~BookmarkBarStateTestBrowserWindow() {} | 97 virtual ~BookmarkBarStateTestBrowserWindow() {} |
98 | 98 |
99 void set_browser(Browser* browser) { browser_ = browser; } | 99 void set_browser(Browser* browser) { browser_ = browser; } |
100 | 100 |
101 BookmarkBar::State bookmark_bar_state() const { | 101 BookmarkBar::State bookmark_bar_state() const { |
102 return bookmark_bar_state_; | 102 return bookmark_bar_state_; |
103 } | 103 } |
104 | 104 |
105 private: | 105 private: |
106 // TestBrowserWindow: | 106 // TestBrowserWindow: |
107 virtual void BookmarkBarStateChanged( | 107 virtual void BookmarkBarStateChanged( |
108 BookmarkBar::AnimateChangeType change_type) OVERRIDE { | 108 BookmarkBar::AnimateChangeType change_type) override { |
109 bookmark_bar_state_ = browser_->bookmark_bar_state(); | 109 bookmark_bar_state_ = browser_->bookmark_bar_state(); |
110 TestBrowserWindow::BookmarkBarStateChanged(change_type); | 110 TestBrowserWindow::BookmarkBarStateChanged(change_type); |
111 } | 111 } |
112 | 112 |
113 virtual void OnActiveTabChanged(content::WebContents* old_contents, | 113 virtual void OnActiveTabChanged(content::WebContents* old_contents, |
114 content::WebContents* new_contents, | 114 content::WebContents* new_contents, |
115 int index, | 115 int index, |
116 int reason) OVERRIDE { | 116 int reason) override { |
117 bookmark_bar_state_ = browser_->bookmark_bar_state(); | 117 bookmark_bar_state_ = browser_->bookmark_bar_state(); |
118 TestBrowserWindow::OnActiveTabChanged(old_contents, new_contents, index, | 118 TestBrowserWindow::OnActiveTabChanged(old_contents, new_contents, index, |
119 reason); | 119 reason); |
120 } | 120 } |
121 | 121 |
122 Browser* browser_; // Weak ptr. | 122 Browser* browser_; // Weak ptr. |
123 BookmarkBar::State bookmark_bar_state_; | 123 BookmarkBar::State bookmark_bar_state_; |
124 | 124 |
125 DISALLOW_COPY_AND_ASSIGN(BookmarkBarStateTestBrowserWindow); | 125 DISALLOW_COPY_AND_ASSIGN(BookmarkBarStateTestBrowserWindow); |
126 }; | 126 }; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 167 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
168 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); | 168 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); |
169 | 169 |
170 // Activate the 2nd tab which is non-NTP. | 170 // Activate the 2nd tab which is non-NTP. |
171 browser()->tab_strip_model()->ActivateTabAt(1, true); | 171 browser()->tab_strip_model()->ActivateTabAt(1, true); |
172 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 172 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
173 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); | 173 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); |
174 } | 174 } |
175 | 175 |
176 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 176 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
OLD | NEW |