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

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

Issue 709813004: Remove the deprecated function ExtensionService::extensions(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed thestig@'s comments. Created 6 years, 1 month 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 "chrome/browser/extensions/extension_browsertest.h" 5 #include "chrome/browser/extensions/extension_browsertest.h"
6 #include "chrome/browser/extensions/extension_service.h"
7 #include "chrome/browser/extensions/test_extension_dir.h" 6 #include "chrome/browser/extensions/test_extension_dir.h"
8 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tabs/tab_strip_model.h" 8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
10 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
11 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
12 #include "content/public/browser/notification_service.h" 11 #include "content/public/browser/notification_service.h"
13 #include "content/public/test/browser_test_utils.h" 12 #include "content/public/test/browser_test_utils.h"
14 #include "extensions/browser/extension_system.h" 13 #include "extensions/browser/extension_registry.h"
15 #include "extensions/common/extension.h" 14 #include "extensions/common/extension.h"
16 #include "extensions/common/value_builder.h" 15 #include "extensions/common/value_builder.h"
17 #include "extensions/test/extension_test_message_listener.h" 16 #include "extensions/test/extension_test_message_listener.h"
18 17
19 namespace extensions { 18 namespace extensions {
20 19
21 // Used to simulate a click on the first element named 'Options'. 20 // Used to simulate a click on the first element named 'Options'.
22 static const char kScriptClickOptionButton[] = 21 static const char kScriptClickOptionButton[] =
23 "(function() { " 22 "(function() { "
24 " var button = document.querySelector('.options-link');" 23 " var button = document.querySelector('.options-link');"
25 " button.click();" 24 " button.click();"
26 "})();"; 25 "})();";
27 26
28 // Test that an extension with an options page makes an 'Options' button appear 27 // Test that an extension with an options page makes an 'Options' button appear
29 // on chrome://extensions, and that clicking the button opens a new tab with the 28 // on chrome://extensions, and that clicking the button opens a new tab with the
30 // extension's options page. 29 // extension's options page.
31 // Disabled because of flakiness. See http://crbug.com/174934. 30 // Disabled because of flakiness. See http://crbug.com/174934.
32 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) { 31 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DISABLED_OptionsPage) {
33 ExtensionService* service = 32 ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
34 ExtensionSystem::Get(browser()->profile())->extension_service(); 33 size_t installed_extensions = registry->enabled_extensions().size();
35 size_t installed_extensions = service->extensions()->size();
36 // Install an extension with an options page. 34 // Install an extension with an options page.
37 const Extension* extension = 35 const Extension* extension =
38 InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1); 36 InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1);
39 ASSERT_TRUE(extension); 37 ASSERT_TRUE(extension);
40 EXPECT_EQ(installed_extensions + 1, service->extensions()->size()); 38 EXPECT_EQ(installed_extensions + 1, registry->enabled_extensions().size());
41 39
42 // Go to the Extension Settings page and click the Options button. 40 // Go to the Extension Settings page and click the Options button.
43 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL)); 41 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL));
44 TabStripModel* tab_strip = browser()->tab_strip_model(); 42 TabStripModel* tab_strip = browser()->tab_strip_model();
45 ui_test_utils::WindowedTabAddedNotificationObserver observer( 43 ui_test_utils::WindowedTabAddedNotificationObserver observer(
46 content::NotificationService::AllSources()); 44 content::NotificationService::AllSources());
47 // NOTE: Currently the above script needs to execute in an iframe. The 45 // NOTE: Currently the above script needs to execute in an iframe. The
48 // selector for that iframe may break if the layout of the extensions 46 // selector for that iframe may break if the layout of the extensions
49 // page changes. 47 // page changes.
50 content::RenderFrameHost* frame = content::FrameMatchingPredicate( 48 content::RenderFrameHost* frame = content::FrameMatchingPredicate(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 scoped_refptr<const Extension> extension = 83 scoped_refptr<const Extension> extension =
86 InstallExtension(extension_dir.Pack(), 1); 84 InstallExtension(extension_dir.Pack(), 1);
87 ASSERT_TRUE(extension.get()); 85 ASSERT_TRUE(extension.get());
88 ui_test_utils::NavigateToURL( 86 ui_test_utils::NavigateToURL(
89 browser(), GURL("chrome://extensions?options=" + extension->id())); 87 browser(), GURL("chrome://extensions?options=" + extension->id()));
90 ASSERT_TRUE(listener.WaitUntilSatisfied()); 88 ASSERT_TRUE(listener.WaitUntilSatisfied());
91 ASSERT_EQ("embedded", listener.message()); 89 ASSERT_EQ("embedded", listener.message());
92 } 90 }
93 91
94 } // namespace extensions 92 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/menu_manager.cc ('k') | chrome/browser/extensions/page_action_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698