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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc

Issue 1878973002: [reland] Makes MaterialDesignController initialization explicit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made it possible to restore MaterialDesignController state after each test case (nits) Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/toolbar/toolbar_actions_bar_unittest.h" 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 static_cast<extensions::TestExtensionSystem*>( 105 static_cast<extensions::TestExtensionSystem*>(
106 extensions::ExtensionSystem::Get(profile())); 106 extensions::ExtensionSystem::Get(profile()));
107 extension_system->CreateExtensionService( 107 extension_system->CreateExtensionService(
108 base::CommandLine::ForCurrentProcess(), 108 base::CommandLine::ForCurrentProcess(),
109 base::FilePath(), 109 base::FilePath(),
110 false); 110 false);
111 toolbar_model_ = 111 toolbar_model_ =
112 extensions::extension_action_test_util::CreateToolbarModelForProfile( 112 extensions::extension_action_test_util::CreateToolbarModelForProfile(
113 profile()); 113 profile());
114 114
115 // Any call by a previous test to MaterialDesignController::GetMode() will 115 material_design_state_.reset(
116 // initialize and cache the mode. This ensures that these tests will run from 116 new ui::test::MaterialDesignControllerTestAPI(GetParam()));
117 // a non-initialized state.
118 ui::test::MaterialDesignControllerTestAPI::UninitializeMode();
119 ui::test::MaterialDesignControllerTestAPI::SetMode(GetParam());
120 ToolbarActionsBar::disable_animations_for_testing_ = true; 117 ToolbarActionsBar::disable_animations_for_testing_ = true;
121 browser_action_test_util_.reset(new BrowserActionTestUtil(browser(), false)); 118 browser_action_test_util_.reset(new BrowserActionTestUtil(browser(), false));
122 119
123 if (use_redesign_) { 120 if (use_redesign_) {
124 overflow_browser_action_test_util_ = 121 overflow_browser_action_test_util_ =
125 browser_action_test_util_->CreateOverflowBar(); 122 browser_action_test_util_->CreateOverflowBar();
126 } 123 }
127 } 124 }
128 125
129 void ToolbarActionsBarUnitTest::TearDown() { 126 void ToolbarActionsBarUnitTest::TearDown() {
130 // Since the profile gets destroyed in BrowserWithTestWindowTest::TearDown(), 127 // Since the profile gets destroyed in BrowserWithTestWindowTest::TearDown(),
131 // we need to delete this now. 128 // we need to delete this now.
132 browser_action_test_util_.reset(); 129 browser_action_test_util_.reset();
133 overflow_browser_action_test_util_.reset(); 130 overflow_browser_action_test_util_.reset();
134 ToolbarActionsBar::disable_animations_for_testing_ = false; 131 ToolbarActionsBar::disable_animations_for_testing_ = false;
135 redesign_switch_.reset(); 132 redesign_switch_.reset();
136 ui::test::MaterialDesignControllerTestAPI::UninitializeMode(); 133 material_design_state_.reset();
137 BrowserWithTestWindowTest::TearDown(); 134 BrowserWithTestWindowTest::TearDown();
138 } 135 }
139 136
140 void ToolbarActionsBarUnitTest::ActivateTab(int index) { 137 void ToolbarActionsBarUnitTest::ActivateTab(int index) {
141 ASSERT_NE(nullptr, browser()->tab_strip_model()->GetWebContentsAt(index)); 138 ASSERT_NE(nullptr, browser()->tab_strip_model()->GetWebContentsAt(index));
142 browser()->tab_strip_model()->ActivateTabAt(index, true); 139 browser()->tab_strip_model()->ActivateTabAt(index, true);
143 } 140 }
144 141
145 scoped_refptr<const extensions::Extension> 142 scoped_refptr<const extensions::Extension>
146 ToolbarActionsBarUnitTest::CreateAndAddExtension( 143 ToolbarActionsBarUnitTest::CreateAndAddExtension(
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 extensions::extension_action_test_util::BROWSER_ACTION); 595 extensions::extension_action_test_util::BROWSER_ACTION);
599 toolbar_model()->SetVisibleIconCount(0u); 596 toolbar_model()->SetVisibleIconCount(0u);
600 { 597 {
601 base::RunLoop run_loop; 598 base::RunLoop run_loop;
602 toolbar_actions_bar()->PopOutAction(action, true, run_loop.QuitClosure()); 599 toolbar_actions_bar()->PopOutAction(action, true, run_loop.QuitClosure());
603 run_loop.Run(); 600 run_loop.Run();
604 } 601 }
605 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount()); 602 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
606 EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow()); 603 EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow());
607 } 604 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698