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

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

Issue 481433005: Extensions: Move id_util functions to crx_file component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert last patchset. function returns Extension* and can't use an assert. Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/extensions/extension_apitest.h" 6 #include "chrome/browser/extensions/extension_apitest.h"
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_test_message_listener.h" 8 #include "chrome/browser/extensions/extension_test_message_listener.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/test/base/test_switches.h" 11 #include "chrome/test/base/test_switches.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "components/crx_file/id_util.h"
13 #include "extensions/browser/extension_system.h" 14 #include "extensions/browser/extension_system.h"
14 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
15 #include "extensions/common/extensions_client.h" 16 #include "extensions/common/extensions_client.h"
16 #include "extensions/common/id_util.h"
17 17
18 const std::string kAllUrlsTarget = 18 const std::string kAllUrlsTarget =
19 "files/extensions/api_test/all_urls/index.html"; 19 "files/extensions/api_test/all_urls/index.html";
20 20
21 typedef ExtensionApiTest AllUrlsApiTest; 21 typedef ExtensionApiTest AllUrlsApiTest;
22 22
23 #if defined(OS_WIN) && !defined(NDEBUG) 23 #if defined(OS_WIN) && !defined(NDEBUG)
24 // http://crbug.com/174341 24 // http://crbug.com/174341
25 #define MAYBE_WhitelistedExtension DISABLED_WhitelistedExtension 25 #define MAYBE_WhitelistedExtension DISABLED_WhitelistedExtension
26 #else 26 #else
27 #define MAYBE_WhitelistedExtension WhitelistedExtension 27 #define MAYBE_WhitelistedExtension WhitelistedExtension
28 #endif 28 #endif
29 IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, MAYBE_WhitelistedExtension) { 29 IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, MAYBE_WhitelistedExtension) {
30 #if defined(OS_WIN) && defined(USE_ASH) 30 #if defined(OS_WIN) && defined(USE_ASH)
31 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 31 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
32 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 32 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
33 return; 33 return;
34 #endif 34 #endif
35 35
36 // First setup the two extensions. 36 // First setup the two extensions.
37 base::FilePath extension_dir1 = test_data_dir_.AppendASCII("all_urls") 37 base::FilePath extension_dir1 = test_data_dir_.AppendASCII("all_urls")
38 .AppendASCII("content_script"); 38 .AppendASCII("content_script");
39 base::FilePath extension_dir2 = test_data_dir_.AppendASCII("all_urls") 39 base::FilePath extension_dir2 = test_data_dir_.AppendASCII("all_urls")
40 .AppendASCII("execute_script"); 40 .AppendASCII("execute_script");
41 41
42 // Then add the two extensions to the whitelist. 42 // Then add the two extensions to the whitelist.
43 extensions::ExtensionsClient::ScriptingWhitelist whitelist; 43 extensions::ExtensionsClient::ScriptingWhitelist whitelist;
44 whitelist.push_back(extensions::id_util::GenerateIdForPath(extension_dir1)); 44 whitelist.push_back(crx_file::id_util::GenerateIdForPath(extension_dir1));
45 whitelist.push_back(extensions::id_util::GenerateIdForPath(extension_dir2)); 45 whitelist.push_back(crx_file::id_util::GenerateIdForPath(extension_dir2));
46 extensions::ExtensionsClient::Get()->SetScriptingWhitelist(whitelist); 46 extensions::ExtensionsClient::Get()->SetScriptingWhitelist(whitelist);
47 47
48 // Then load extensions. 48 // Then load extensions.
49 ExtensionService* service = extensions::ExtensionSystem::Get( 49 ExtensionService* service = extensions::ExtensionSystem::Get(
50 browser()->profile())->extension_service(); 50 browser()->profile())->extension_service();
51 const size_t size_before = service->extensions()->size(); 51 const size_t size_before = service->extensions()->size();
52 ASSERT_TRUE(LoadExtension(extension_dir1)); 52 ASSERT_TRUE(LoadExtension(extension_dir1));
53 ASSERT_TRUE(LoadExtension(extension_dir2)); 53 ASSERT_TRUE(LoadExtension(extension_dir2));
54 EXPECT_EQ(size_before + 2, service->extensions()->size()); 54 EXPECT_EQ(size_before + 2, service->extensions()->size());
55 55
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Now verify we can script a regular http page. 117 // Now verify we can script a regular http page.
118 ASSERT_TRUE(test_server()->Start()); 118 ASSERT_TRUE(test_server()->Start());
119 GURL page_url = test_server()->GetURL(kAllUrlsTarget); 119 GURL page_url = test_server()->GetURL(kAllUrlsTarget);
120 ExtensionTestMessageListener listener1a("content script: " + page_url.spec(), 120 ExtensionTestMessageListener listener1a("content script: " + page_url.spec(),
121 false); 121 false);
122 ExtensionTestMessageListener listener1b("execute: " + page_url.spec(), false); 122 ExtensionTestMessageListener listener1b("execute: " + page_url.spec(), false);
123 ui_test_utils::NavigateToURL(browser(), page_url); 123 ui_test_utils::NavigateToURL(browser(), page_url);
124 ASSERT_TRUE(listener1a.WaitUntilSatisfied()); 124 ASSERT_TRUE(listener1a.WaitUntilSatisfied());
125 ASSERT_TRUE(listener1b.WaitUntilSatisfied()); 125 ASSERT_TRUE(listener1b.WaitUntilSatisfied());
126 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698