| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 namespace extensions { | 35 namespace extensions { |
| 36 namespace { | 36 namespace { |
| 37 | 37 |
| 38 class LocationBarControllerUnitTest : public ChromeRenderViewHostTestHarness { | 38 class LocationBarControllerUnitTest : public ChromeRenderViewHostTestHarness { |
| 39 protected: | 39 protected: |
| 40 void SetUp() override { | 40 void SetUp() override { |
| 41 active_script_override_.reset(new FeatureSwitch::ScopedOverride( | 41 active_script_override_.reset(new FeatureSwitch::ScopedOverride( |
| 42 FeatureSwitch::scripts_require_action(), true)); | 42 FeatureSwitch::scripts_require_action(), true)); |
| 43 extension_action_override_.reset(new FeatureSwitch::ScopedOverride( |
| 44 FeatureSwitch::extension_action_redesign(), false)); |
| 43 | 45 |
| 44 ChromeRenderViewHostTestHarness::SetUp(); | 46 ChromeRenderViewHostTestHarness::SetUp(); |
| 45 #if defined OS_CHROMEOS | 47 #if defined OS_CHROMEOS |
| 46 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); | 48 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); |
| 47 #endif | 49 #endif |
| 48 TabHelper::CreateForWebContents(web_contents()); | 50 TabHelper::CreateForWebContents(web_contents()); |
| 49 // Create an ExtensionService so the LocationBarController can find its | 51 // Create an ExtensionService so the LocationBarController can find its |
| 50 // extensions. | 52 // extensions. |
| 51 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 53 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 52 Profile* profile = | 54 Profile* profile = |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 private: | 94 private: |
| 93 #if defined OS_CHROMEOS | 95 #if defined OS_CHROMEOS |
| 94 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 96 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 95 chromeos::ScopedTestCrosSettings test_cros_settings_; | 97 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 96 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; | 98 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
| 97 #endif | 99 #endif |
| 98 | 100 |
| 99 // Since we also test that we show page actions for pending script requests, | 101 // Since we also test that we show page actions for pending script requests, |
| 100 // we need to enable that feature. | 102 // we need to enable that feature. |
| 101 scoped_ptr<FeatureSwitch::ScopedOverride> active_script_override_; | 103 scoped_ptr<FeatureSwitch::ScopedOverride> active_script_override_; |
| 104 |
| 105 // This tests legacy page actions. |
| 106 scoped_ptr<FeatureSwitch::ScopedOverride> extension_action_override_; |
| 102 }; | 107 }; |
| 103 | 108 |
| 104 // Test that the location bar gets the proper current actions. | 109 // Test that the location bar gets the proper current actions. |
| 105 TEST_F(LocationBarControllerUnitTest, LocationBarDisplaysPageActions) { | 110 TEST_F(LocationBarControllerUnitTest, LocationBarDisplaysPageActions) { |
| 106 // Load up two extensions, one with a page action and one without. | 111 // Load up two extensions, one with a page action and one without. |
| 107 const Extension* page_action = AddExtension(true, "page_actions"); | 112 const Extension* page_action = AddExtension(true, "page_actions"); |
| 108 const Extension* no_action = AddExtension(false, "no_actions"); | 113 const Extension* no_action = AddExtension(false, "no_actions"); |
| 109 | 114 |
| 110 TabHelper* tab_helper = TabHelper::FromWebContents(web_contents()); | 115 TabHelper* tab_helper = TabHelper::FromWebContents(web_contents()); |
| 111 ASSERT_TRUE(tab_helper); | 116 ASSERT_TRUE(tab_helper); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 NavigateAndCommit(GURL("http://www.yahoo.com")); | 196 NavigateAndCommit(GURL("http://www.yahoo.com")); |
| 192 | 197 |
| 193 EXPECT_EQ("Hello", page_action.GetTitle(tab_id())); | 198 EXPECT_EQ("Hello", page_action.GetTitle(tab_id())); |
| 194 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id())); | 199 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id())); |
| 195 EXPECT_FALSE( | 200 EXPECT_FALSE( |
| 196 extension_action_api->PageActionWantsToRun(extension, web_contents())); | 201 extension_action_api->PageActionWantsToRun(extension, web_contents())); |
| 197 } | 202 } |
| 198 | 203 |
| 199 } // namespace | 204 } // namespace |
| 200 } // namespace extensions | 205 } // namespace extensions |
| OLD | NEW |