Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/browser/ui/browser_unittest.cc

Issue 2737553004: Set background color when adding a new tab. (Closed)
Patch Set: none Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/ui/browser_command_controller.h" 9 #include "chrome/browser/ui/browser_command_controller.h"
10 #include "chrome/browser/ui/browser_commands.h" 10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/test/base/browser_with_test_window_test.h" 12 #include "chrome/test/base/browser_with_test_window_test.h"
13 #include "components/zoom/zoom_controller.h" 13 #include "components/zoom/zoom_controller.h"
14 #include "content/public/browser/render_widget_host_view.h"
14 #include "content/public/browser/site_instance.h" 15 #include "content/public/browser/site_instance.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 #include "content/public/test/web_contents_tester.h" 17 #include "content/public/test/web_contents_tester.h"
18 #include "third_party/skia/include/core/SkColor.h"
17 19
18 using content::SiteInstance; 20 using content::SiteInstance;
19 using content::WebContents; 21 using content::WebContents;
20 using content::WebContentsTester; 22 using content::WebContentsTester;
21 23
22 class BrowserUnitTest : public BrowserWithTestWindowTest { 24 class BrowserUnitTest : public BrowserWithTestWindowTest {
23 public: 25 public:
24 BrowserUnitTest() {} 26 BrowserUnitTest() {}
25 ~BrowserUnitTest() override {} 27 ~BrowserUnitTest() override {}
26 28
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 contents2->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1); 61 contents2->SetIsCrashed(base::TERMINATION_STATUS_PROCESS_CRASHED, -1);
60 EXPECT_TRUE(contents2->IsCrashed()); 62 EXPECT_TRUE(contents2->IsCrashed());
61 63
62 // Selecting the second tab does not cause a load or clear the crash. 64 // Selecting the second tab does not cause a load or clear the crash.
63 tab_strip_model->ActivateTabAt(1, true); 65 tab_strip_model->ActivateTabAt(1, true);
64 EXPECT_TRUE(tab_strip_model->IsTabSelected(1)); 66 EXPECT_TRUE(tab_strip_model->IsTabSelected(1));
65 EXPECT_FALSE(contents2->IsLoading()); 67 EXPECT_FALSE(contents2->IsLoading());
66 EXPECT_TRUE(contents2->IsCrashed()); 68 EXPECT_TRUE(contents2->IsCrashed());
67 } 69 }
68 70
71 TEST_F(BrowserUnitTest, SetBackgroundColorForNewTab) {
72 TabStripModel* tab_strip_model = browser()->tab_strip_model();
73
74 WebContents* contents1 = CreateTestWebContents();
75 tab_strip_model->AppendWebContents(contents1, true);
76 WebContentsTester::For(contents1)->NavigateAndCommit(GURL("about:blank"));
77 WebContentsTester::For(contents1)->TestSetIsLoading(false);
78
79 contents1->GetMainFrame()->GetView()->SetBackgroundColor(SK_ColorRED);
80
81 // Add a second tab in the background.
82 WebContents* contents2 = CreateTestWebContents();
83 tab_strip_model->AppendWebContents(contents2, false);
84 WebContentsTester::For(contents2)->NavigateAndCommit(GURL("about:blank"));
85 WebContentsTester::For(contents2)->TestSetIsLoading(false);
86
87 tab_strip_model->ActivateTabAt(1, true);
88 EXPECT_EQ(SK_ColorRED,
89 contents2->GetMainFrame()->GetView()->background_color());
90 }
91
69 // Ensure the print command gets disabled when a tab crashes. 92 // Ensure the print command gets disabled when a tab crashes.
70 TEST_F(BrowserUnitTest, DisablePrintOnCrashedTab) { 93 TEST_F(BrowserUnitTest, DisablePrintOnCrashedTab) {
71 TabStripModel* tab_strip_model = browser()->tab_strip_model(); 94 TabStripModel* tab_strip_model = browser()->tab_strip_model();
72 95
73 WebContents* contents = CreateTestWebContents(); 96 WebContents* contents = CreateTestWebContents();
74 tab_strip_model->AppendWebContents(contents, true); 97 tab_strip_model->AppendWebContents(contents, true);
75 WebContentsTester::For(contents)->NavigateAndCommit(GURL("about:blank")); 98 WebContentsTester::For(contents)->NavigateAndCommit(GURL("about:blank"));
76 99
77 CommandUpdater* command_updater = 100 CommandUpdater* command_updater =
78 browser()->command_controller()->command_updater(); 101 browser()->command_controller()->command_updater();
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 // Activate the 1st tab which is NTP. 241 // Activate the 1st tab which is NTP.
219 browser()->tab_strip_model()->ActivateTabAt(0, true); 242 browser()->tab_strip_model()->ActivateTabAt(0, true);
220 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 243 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
221 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); 244 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state());
222 245
223 // Activate the 2nd tab which is non-NTP. 246 // Activate the 2nd tab which is non-NTP.
224 browser()->tab_strip_model()->ActivateTabAt(1, true); 247 browser()->tab_strip_model()->ActivateTabAt(1, true);
225 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 248 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
226 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state()); 249 EXPECT_EQ(BookmarkBar::SHOW, window_bookmark_bar_state());
227 } 250 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698