Chromium Code Reviews| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | |
| 9 #include "chrome/browser/ui/browser_command_controller.h" | |
| 8 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 10 #include "chrome/test/base/browser_with_test_window_test.h" | 12 #include "chrome/test/base/browser_with_test_window_test.h" |
| 11 #include "content/public/browser/site_instance.h" | 13 #include "content/public/browser/site_instance.h" |
| 12 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/test/web_contents_tester.h" | 15 #include "content/public/test/web_contents_tester.h" |
| 14 | 16 |
| 15 using content::SiteInstance; | 17 using content::SiteInstance; |
| 16 using content::WebContents; | 18 using content::WebContents; |
| 17 using content::WebContentsTester; | 19 using content::WebContentsTester; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 contents2->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | 58 contents2->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); |
| 57 EXPECT_TRUE(contents2->IsCrashed()); | 59 EXPECT_TRUE(contents2->IsCrashed()); |
| 58 | 60 |
| 59 // Selecting the second tab does not cause a load or clear the crash. | 61 // Selecting the second tab does not cause a load or clear the crash. |
| 60 tab_strip_model->ActivateTabAt(1, true); | 62 tab_strip_model->ActivateTabAt(1, true); |
| 61 EXPECT_TRUE(tab_strip_model->IsTabSelected(1)); | 63 EXPECT_TRUE(tab_strip_model->IsTabSelected(1)); |
| 62 EXPECT_FALSE(contents2->IsLoading()); | 64 EXPECT_FALSE(contents2->IsLoading()); |
| 63 EXPECT_TRUE(contents2->IsCrashed()); | 65 EXPECT_TRUE(contents2->IsCrashed()); |
| 64 } | 66 } |
| 65 | 67 |
| 68 // Ensure the print command gets disabled when a tab crashes. | |
| 69 TEST_F(BrowserUnitTest, DisablePrintOnCrashedTab) { | |
| 70 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | |
| 71 | |
| 72 WebContents* contents = CreateTestWebContents(); | |
| 73 tab_strip_model->AppendWebContents(contents, true); | |
| 74 WebContentsTester::For(contents)->NavigateAndCommit(GURL("about:blank")); | |
| 75 | |
| 76 CommandUpdater* command_updater = | |
| 77 browser()->command_controller()->command_updater(); | |
| 78 | |
| 79 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); | |
| 80 EXPECT_TRUE(chrome::CanPrint(browser())); | |
| 81 EXPECT_FALSE(contents->IsCrashed()); | |
|
Peter Kasting
2016/03/31 21:59:05
Nit: Move the IsCrashed() check to the top of each
| |
| 82 | |
| 83 contents->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); | |
| 84 | |
| 85 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_PRINT)); | |
| 86 EXPECT_FALSE(chrome::CanPrint(browser())); | |
| 87 EXPECT_TRUE(contents->IsCrashed()); | |
| 88 } | |
| 89 | |
| 66 class BrowserBookmarkBarTest : public BrowserWithTestWindowTest { | 90 class BrowserBookmarkBarTest : public BrowserWithTestWindowTest { |
| 67 public: | 91 public: |
| 68 BrowserBookmarkBarTest() {} | 92 BrowserBookmarkBarTest() {} |
| 69 ~BrowserBookmarkBarTest() override {} | 93 ~BrowserBookmarkBarTest() override {} |
| 70 | 94 |
| 71 protected: | 95 protected: |
| 72 BookmarkBar::State window_bookmark_bar_state() const { | 96 BookmarkBar::State window_bookmark_bar_state() const { |
| 73 return static_cast<BookmarkBarStateTestBrowserWindow*>( | 97 return static_cast<BookmarkBarStateTestBrowserWindow*>( |
| 74 browser()->window())->bookmark_bar_state(); | 98 browser()->window())->bookmark_bar_state(); |
| 75 } | 99 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 // Activate the 1st tab which is NTP. | 186 // Activate the 1st tab which is NTP. |
| 163 browser()->tab_strip_model()->ActivateTabAt(0, true); | 187 browser()->tab_strip_model()->ActivateTabAt(0, true); |
| 164 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 188 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 165 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); | 189 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); |
| 166 | 190 |
| 167 // Activate the 2nd tab which is non-NTP. | 191 // Activate the 2nd tab which is non-NTP. |
| 168 browser()->tab_strip_model()->ActivateTabAt(1, true); | 192 browser()->tab_strip_model()->ActivateTabAt(1, true); |
| 169 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); | 193 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); |
| 170 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); | 194 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); |
| 171 } | 195 } |
| OLD | NEW |