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

Side by Side Diff: chrome/browser/extensions/location_bar_controller_unittest.cc

Issue 508563003: Remove PageActionsController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 (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 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/extensions/extension_action.h" 10 #include "chrome/browser/extensions/extension_action.h"
11 #include "chrome/browser/extensions/extension_action_manager.h" 11 #include "chrome/browser/extensions/extension_action_manager.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/page_action_controller.h"
14 #include "chrome/browser/extensions/tab_helper.h" 13 #include "chrome/browser/extensions/tab_helper.h"
15 #include "chrome/browser/extensions/test_extension_system.h" 14 #include "chrome/browser/extensions/test_extension_system.h"
16 #include "chrome/browser/sessions/session_tab_helper.h" 15 #include "chrome/browser/sessions/session_tab_helper.h"
17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 16 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
18 #include "chrome/test/base/testing_profile.h" 17 #include "chrome/test/base/testing_profile.h"
19 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
20 #include "extensions/common/extension_builder.h" 19 #include "extensions/common/extension_builder.h"
21 #include "extensions/common/value_builder.h" 20 #include "extensions/common/value_builder.h"
22 21
23 #if defined(OS_CHROMEOS) 22 #if defined(OS_CHROMEOS)
24 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" 23 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
25 #include "chrome/browser/chromeos/settings/cros_settings.h" 24 #include "chrome/browser/chromeos/settings/cros_settings.h"
26 #include "chrome/browser/chromeos/settings/device_settings_service.h" 25 #include "chrome/browser/chromeos/settings/device_settings_service.h"
27 #endif 26 #endif
28 27
29 namespace extensions { 28 namespace extensions {
30 namespace { 29 namespace {
31 30
32 class PageActionControllerTest : public ChromeRenderViewHostTestHarness { 31 class LocationBarControllerUnitTest : public ChromeRenderViewHostTestHarness {
33 protected: 32 protected:
34 virtual void SetUp() OVERRIDE { 33 virtual void SetUp() OVERRIDE {
35 ChromeRenderViewHostTestHarness::SetUp(); 34 ChromeRenderViewHostTestHarness::SetUp();
36 #if defined OS_CHROMEOS 35 #if defined OS_CHROMEOS
37 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); 36 test_user_manager_.reset(new chromeos::ScopedTestUserManager());
38 #endif 37 #endif
39 TabHelper::CreateForWebContents(web_contents()); 38 TabHelper::CreateForWebContents(web_contents());
40 // Create an ExtensionService so the PageActionController can find its 39 // Create an ExtensionService so the LocationBarController can find its
41 // extensions. 40 // extensions.
42 CommandLine command_line(CommandLine::NO_PROGRAM); 41 CommandLine command_line(CommandLine::NO_PROGRAM);
43 Profile* profile = 42 Profile* profile =
44 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 43 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
45 extension_service_ = static_cast<TestExtensionSystem*>( 44 extension_service_ = static_cast<TestExtensionSystem*>(
46 ExtensionSystem::Get(profile))->CreateExtensionService( 45 ExtensionSystem::Get(profile))->CreateExtensionService(
47 &command_line, base::FilePath(), false); 46 &command_line, base::FilePath(), false);
48 } 47 }
49 48
50 virtual void TearDown() OVERRIDE { 49 virtual void TearDown() OVERRIDE {
(...skipping 10 matching lines...) Expand all
61 ExtensionService* extension_service_; 60 ExtensionService* extension_service_;
62 61
63 private: 62 private:
64 #if defined OS_CHROMEOS 63 #if defined OS_CHROMEOS
65 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 64 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
66 chromeos::ScopedTestCrosSettings test_cros_settings_; 65 chromeos::ScopedTestCrosSettings test_cros_settings_;
67 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; 66 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
68 #endif 67 #endif
69 }; 68 };
70 69
71 TEST_F(PageActionControllerTest, NavigationClearsState) { 70 // Test that navigating clears all state in a page action.
71 TEST_F(LocationBarControllerUnitTest, NavigationClearsState) {
72 scoped_refptr<const Extension> extension = 72 scoped_refptr<const Extension> extension =
73 ExtensionBuilder() 73 ExtensionBuilder()
74 .SetManifest(DictionaryBuilder() 74 .SetManifest(DictionaryBuilder()
75 .Set("name", "Extension with page action") 75 .Set("name", "Extension with page action")
76 .Set("version", "1.0.0") 76 .Set("version", "1.0.0")
77 .Set("manifest_version", 2) 77 .Set("manifest_version", 2)
78 .Set("permissions", ListBuilder() 78 .Set("permissions", ListBuilder()
79 .Append("tabs")) 79 .Append("tabs"))
80 .Set("page_action", DictionaryBuilder() 80 .Set("page_action", DictionaryBuilder()
81 .Set("default_title", "Hello"))) 81 .Set("default_title", "Hello")))
(...skipping 19 matching lines...) Expand all
101 EXPECT_EQ(extension->GetResourceURL("popup.html"), 101 EXPECT_EQ(extension->GetResourceURL("popup.html"),
102 page_action.GetPopupUrl(tab_id())); 102 page_action.GetPopupUrl(tab_id()));
103 103
104 // Should discard the settings, and go back to the defaults. 104 // Should discard the settings, and go back to the defaults.
105 NavigateAndCommit(GURL("http://www.yahoo.com")); 105 NavigateAndCommit(GURL("http://www.yahoo.com"));
106 106
107 EXPECT_EQ("Hello", page_action.GetTitle(tab_id())); 107 EXPECT_EQ("Hello", page_action.GetTitle(tab_id()));
108 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id())); 108 EXPECT_EQ(GURL(), page_action.GetPopupUrl(tab_id()));
109 }; 109 };
110 110
111 // TODO(devlin): We should really have more tests for this.
112 // NavigationClearsState doesn't test at all that the LocationBarController
113 // actually *returns* the proper PageActions in GetCurrentActions. Do we do
114 // this elsewhere?
Finnur 2014/08/27 16:00:15 Not sure. Probably not.
115
111 } // namespace 116 } // namespace
112 } // namespace extensions 117 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/location_bar_controller.cc ('k') | chrome/browser/extensions/page_action_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698