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" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 #include "content/public/test/web_contents_tester.h" | 12 #include "content/public/test/web_contents_tester.h" |
13 | 13 |
14 // Both tests below require a tab strip, so skip the file entirely on platforms | 14 // Both tests below require a tab strip, so skip the file entirely on platforms |
15 // without one. | 15 // without one. |
16 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 16 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
17 | 17 |
18 using content::SiteInstance; | 18 using content::SiteInstance; |
19 using content::WebContents; | 19 using content::WebContents; |
20 using content::WebContentsTester; | 20 using content::WebContentsTester; |
21 | 21 |
22 class BrowserUnitTest : public BrowserWithTestWindowTest { | 22 class BrowserUnitTest : public BrowserWithTestWindowTest { |
23 public: | 23 public: |
24 BrowserUnitTest() {} | 24 BrowserUnitTest() {} |
25 virtual ~BrowserUnitTest() {} | 25 ~BrowserUnitTest() override {} |
26 | 26 |
27 // Caller owns the memory. | 27 // Caller owns the memory. |
28 WebContents* CreateTestWebContents() { | 28 WebContents* CreateTestWebContents() { |
29 return WebContentsTester::CreateTestWebContents( | 29 return WebContentsTester::CreateTestWebContents( |
30 profile(), SiteInstance::Create(profile())); | 30 profile(), SiteInstance::Create(profile())); |
31 } | 31 } |
32 | 32 |
33 private: | 33 private: |
34 DISALLOW_COPY_AND_ASSIGN(BrowserUnitTest); | 34 DISALLOW_COPY_AND_ASSIGN(BrowserUnitTest); |
35 }; | 35 }; |
(...skipping 26 matching lines...) Expand all Loading... |
62 // Selecting the second tab does not cause a load or clear the crash. | 62 // Selecting the second tab does not cause a load or clear the crash. |
63 tab_strip_model->ActivateTabAt(1, true); | 63 tab_strip_model->ActivateTabAt(1, true); |
64 EXPECT_TRUE(tab_strip_model->IsTabSelected(1)); | 64 EXPECT_TRUE(tab_strip_model->IsTabSelected(1)); |
65 EXPECT_FALSE(contents2->IsLoading()); | 65 EXPECT_FALSE(contents2->IsLoading()); |
66 EXPECT_TRUE(contents2->IsCrashed()); | 66 EXPECT_TRUE(contents2->IsCrashed()); |
67 } | 67 } |
68 | 68 |
69 class BrowserBookmarkBarTest : public BrowserWithTestWindowTest { | 69 class BrowserBookmarkBarTest : public BrowserWithTestWindowTest { |
70 public: | 70 public: |
71 BrowserBookmarkBarTest() {} | 71 BrowserBookmarkBarTest() {} |
72 virtual ~BrowserBookmarkBarTest() {} | 72 ~BrowserBookmarkBarTest() override {} |
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 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 BrowserWindow* CreateBrowserWindow() override { | 87 BrowserWindow* CreateBrowserWindow() override { |
88 return new BookmarkBarStateTestBrowserWindow(); | 88 return new BookmarkBarStateTestBrowserWindow(); |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
(...skipping 75 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 |