| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_UNITTEST_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_UNITTEST_H_ |
| 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_UNITTEST_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_UNITTEST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chrome/browser/extensions/browser_action_test_util.h" | 13 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 14 #include "chrome/browser/extensions/extension_action_test_util.h" | 14 #include "chrome/browser/extensions/extension_action_test_util.h" |
| 15 #include "chrome/test/base/browser_with_test_window_test.h" | 15 #include "chrome/test/base/browser_with_test_window_test.h" |
| 16 #include "extensions/common/feature_switch.h" | |
| 17 #include "ui/base/material_design/material_design_controller.h" | 16 #include "ui/base/material_design/material_design_controller.h" |
| 18 | 17 |
| 19 class ExtensionAction; | 18 class ExtensionAction; |
| 20 class ToolbarActionsBar; | 19 class ToolbarActionsBar; |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| 23 class WebContents; | 22 class WebContents; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace extensions { | 25 namespace extensions { |
| 27 class Extension; | 26 class Extension; |
| 28 } | 27 } |
| 29 | 28 |
| 30 // A cross-platform unit test for the ToolbarActionsBar that uses the | 29 // A cross-platform unit test for the ToolbarActionsBar that uses the |
| 31 // TestToolbarActionsBarHelper to create the platform-specific containers. | 30 // TestToolbarActionsBarHelper to create the platform-specific containers. |
| 32 // TODO(devlin): Since this *does* use the real platform containers, in theory, | 31 // TODO(devlin): Since this *does* use the real platform containers, in theory, |
| 33 // we can move all the BrowserActionsBarBrowserTests to be unittests. See about | 32 // we can move all the BrowserActionsBarBrowserTests to be unittests. See about |
| 34 // doing this. | 33 // doing this. |
| 35 class ToolbarActionsBarUnitTest : | 34 class ToolbarActionsBarUnitTest : |
| 36 public BrowserWithTestWindowTest, | 35 public BrowserWithTestWindowTest, |
| 37 public testing::WithParamInterface<ui::MaterialDesignController::Mode> { | 36 public testing::WithParamInterface<ui::MaterialDesignController::Mode> { |
| 38 public: | 37 public: |
| 39 ToolbarActionsBarUnitTest(); | 38 ToolbarActionsBarUnitTest(); |
| 40 ~ToolbarActionsBarUnitTest() override; | 39 ~ToolbarActionsBarUnitTest() override; |
| 41 | 40 |
| 42 protected: | 41 protected: |
| 43 // A constructor to allow subclasses to override the redesign value. | |
| 44 explicit ToolbarActionsBarUnitTest(bool use_redesign); | |
| 45 | |
| 46 void SetUp() override; | 42 void SetUp() override; |
| 47 void TearDown() override; | 43 void TearDown() override; |
| 48 | 44 |
| 49 // Activates the tab at the given |index| in the tab strip model. | 45 // Activates the tab at the given |index| in the tab strip model. |
| 50 void ActivateTab(int index); | 46 void ActivateTab(int index); |
| 51 | 47 |
| 52 // Set whether or not the given |action| wants to run on the |web_contents|. | 48 // Set whether or not the given |action| wants to run on the |web_contents|. |
| 53 void SetActionWantsToRunOnTab(ExtensionAction* action, | 49 void SetActionWantsToRunOnTab(ExtensionAction* action, |
| 54 content::WebContents* web_contents, | 50 content::WebContents* web_contents, |
| 55 bool wants_to_run); | 51 bool wants_to_run); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 86 } |
| 91 | 87 |
| 92 private: | 88 private: |
| 93 // The associated ToolbarActionsModel (owned by the keyed service setup). | 89 // The associated ToolbarActionsModel (owned by the keyed service setup). |
| 94 ToolbarActionsModel* toolbar_model_; | 90 ToolbarActionsModel* toolbar_model_; |
| 95 | 91 |
| 96 // A BrowserActionTestUtil object constructed with the associated | 92 // A BrowserActionTestUtil object constructed with the associated |
| 97 // ToolbarActionsBar. | 93 // ToolbarActionsBar. |
| 98 std::unique_ptr<BrowserActionTestUtil> browser_action_test_util_; | 94 std::unique_ptr<BrowserActionTestUtil> browser_action_test_util_; |
| 99 | 95 |
| 100 // The overflow container's BrowserActionTestUtil (only non-null if | 96 // The overflow container's BrowserActionTestUtil. |
| 101 // |use_redesign| is true). | |
| 102 std::unique_ptr<BrowserActionTestUtil> overflow_browser_action_test_util_; | 97 std::unique_ptr<BrowserActionTestUtil> overflow_browser_action_test_util_; |
| 103 | 98 |
| 104 // True if the extension action redesign switch should be enabled. | |
| 105 bool use_redesign_; | |
| 106 | |
| 107 std::unique_ptr<extensions::FeatureSwitch::ScopedOverride> redesign_switch_; | |
| 108 | |
| 109 std::unique_ptr<ui::test::MaterialDesignControllerTestAPI> | 99 std::unique_ptr<ui::test::MaterialDesignControllerTestAPI> |
| 110 material_design_state_; | 100 material_design_state_; |
| 111 | 101 |
| 112 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarUnitTest); | 102 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarUnitTest); |
| 113 }; | 103 }; |
| 114 | 104 |
| 115 class ToolbarActionsBarRedesignUnitTest : public ToolbarActionsBarUnitTest { | |
| 116 public: | |
| 117 ToolbarActionsBarRedesignUnitTest(); | |
| 118 ~ToolbarActionsBarRedesignUnitTest() override; | |
| 119 | |
| 120 private: | |
| 121 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarRedesignUnitTest); | |
| 122 }; | |
| 123 | |
| 124 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_UNITTEST_H_ | 105 #endif // CHROME_BROWSER_UI_TOOLBAR_TOOLBAR_ACTIONS_BAR_UNITTEST_H_ |
| OLD | NEW |