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

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

Issue 11724002: Move ContentScripts out of Extension (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: Created 7 years, 9 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/json/json_file_value_serializer.h" 6 #include "base/json/json_file_value_serializer.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/management_policy.h" 11 #include "chrome/browser/extensions/management_policy.h"
12 #include "chrome/browser/extensions/test_extension_system.h" 12 #include "chrome/browser/extensions/test_extension_system.h"
13 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" 13 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
14 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
15 #include "chrome/common/extensions/api/content_scripts/content_scripts_handler.h "
15 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/manifest_handler.h"
16 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
17 #include "content/public/test/test_browser_thread.h" 19 #include "content/public/test/test_browser_thread.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 21
20 using extensions::Extension; 22 using extensions::Extension;
21 using extensions::Manifest; 23 using extensions::Manifest;
22 24
23 class ExtensionUITest : public testing::Test { 25 class ExtensionUITest : public testing::Test {
24 public: 26 public:
25 ExtensionUITest() 27 ExtensionUITest()
26 : ui_thread_(content::BrowserThread::UI, &message_loop_), 28 : ui_thread_(content::BrowserThread::UI, &message_loop_),
27 file_thread_(content::BrowserThread::FILE, &message_loop_) {} 29 file_thread_(content::BrowserThread::FILE, &message_loop_) {}
28 30
29 protected: 31 protected:
30 virtual void SetUp() OVERRIDE { 32 virtual void SetUp() OVERRIDE {
33 testing::Test::SetUp();
34
31 // Create an ExtensionService and ManagementPolicy to inject into the 35 // Create an ExtensionService and ManagementPolicy to inject into the
32 // ExtensionSettingsHandler. 36 // ExtensionSettingsHandler.
33 profile_.reset(new TestingProfile()); 37 profile_.reset(new TestingProfile());
34 extensions::TestExtensionSystem* system = 38 extensions::TestExtensionSystem* system =
35 static_cast<extensions::TestExtensionSystem*>( 39 static_cast<extensions::TestExtensionSystem*>(
36 extensions::ExtensionSystem::Get(profile_.get())); 40 extensions::ExtensionSystem::Get(profile_.get()));
37 extension_service_ = system->CreateExtensionService( 41 extension_service_ = system->CreateExtensionService(
38 CommandLine::ForCurrentProcess(), base::FilePath(), false); 42 CommandLine::ForCurrentProcess(), base::FilePath(), false);
39 management_policy_ = system->management_policy(); 43 management_policy_ = system->management_policy();
40 44
41 handler_.reset(new ExtensionSettingsHandler(extension_service_, 45 handler_.reset(new ExtensionSettingsHandler(extension_service_,
42 management_policy_)); 46 management_policy_));
47
48 (new extensions::ContentScriptsHandler)->Register();
43 } 49 }
44 50
45 virtual void TearDown() OVERRIDE { 51 virtual void TearDown() OVERRIDE {
46 handler_.reset(); 52 handler_.reset();
47 profile_.reset(); 53 profile_.reset();
48 // Execute any pending deletion tasks. 54 // Execute any pending deletion tasks.
49 message_loop_.RunUntilIdle(); 55 message_loop_.RunUntilIdle();
56 extensions::ManifestHandler::ClearRegistryForTesting();
57 testing::Test::TearDown();
50 } 58 }
51 59
52 static DictionaryValue* DeserializeJSONTestData(const base::FilePath& path, 60 static DictionaryValue* DeserializeJSONTestData(const base::FilePath& path,
53 std::string *error) { 61 std::string *error) {
54 Value* value; 62 Value* value;
55 63
56 JSONFileValueSerializer serializer(path); 64 JSONFileValueSerializer serializer(path);
57 value = serializer.Deserialize(NULL, error); 65 value = serializer.Deserialize(NULL, error);
58 66
59 return static_cast<DictionaryValue*>(value); 67 return static_cast<DictionaryValue*>(value);
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 267
260 scoped_ptr<DictionaryValue> extension_details( 268 scoped_ptr<DictionaryValue> extension_details(
261 CreateExtensionDetailViewFromPath( 269 CreateExtensionDetailViewFromPath(
262 extension_path, pages, Manifest::UNPACKED)); 270 extension_path, pages, Manifest::UNPACKED));
263 271
264 base::FilePath::StringType ui_path; 272 base::FilePath::StringType ui_path;
265 273
266 EXPECT_TRUE(extension_details->GetString("path", &ui_path)); 274 EXPECT_TRUE(extension_details->GetString("path", &ui_path));
267 EXPECT_EQ(extension_path, base::FilePath(ui_path)); 275 EXPECT_EQ(extension_path, base::FilePath(ui_path));
268 } 276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698