| 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 "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/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/extensions/manifest_handler.h" |
| 17 #include "chrome/common/extensions/manifest_handlers/content_scripts_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 "extensions/common/constants.h" | 20 #include "extensions/common/constants.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 22 |
| 21 using extensions::Extension; | 23 using extensions::Extension; |
| 22 using extensions::Manifest; | 24 using extensions::Manifest; |
| 23 | 25 |
| 24 class ExtensionUITest : public testing::Test { | 26 class ExtensionUITest : public testing::Test { |
| 25 public: | 27 public: |
| 26 ExtensionUITest() | 28 ExtensionUITest() |
| 27 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 29 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 28 file_thread_(content::BrowserThread::FILE, &message_loop_) {} | 30 file_thread_(content::BrowserThread::FILE, &message_loop_) {} |
| 29 | 31 |
| 30 protected: | 32 protected: |
| 31 virtual void SetUp() OVERRIDE { | 33 virtual void SetUp() OVERRIDE { |
| 34 testing::Test::SetUp(); |
| 35 |
| 32 // Create an ExtensionService and ManagementPolicy to inject into the | 36 // Create an ExtensionService and ManagementPolicy to inject into the |
| 33 // ExtensionSettingsHandler. | 37 // ExtensionSettingsHandler. |
| 34 profile_.reset(new TestingProfile()); | 38 profile_.reset(new TestingProfile()); |
| 35 extensions::TestExtensionSystem* system = | 39 extensions::TestExtensionSystem* system = |
| 36 static_cast<extensions::TestExtensionSystem*>( | 40 static_cast<extensions::TestExtensionSystem*>( |
| 37 extensions::ExtensionSystem::Get(profile_.get())); | 41 extensions::ExtensionSystem::Get(profile_.get())); |
| 38 extension_service_ = system->CreateExtensionService( | 42 extension_service_ = system->CreateExtensionService( |
| 39 CommandLine::ForCurrentProcess(), base::FilePath(), false); | 43 CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 40 management_policy_ = system->management_policy(); | 44 management_policy_ = system->management_policy(); |
| 41 | 45 |
| 42 handler_.reset(new ExtensionSettingsHandler(extension_service_, | 46 handler_.reset(new ExtensionSettingsHandler(extension_service_, |
| 43 management_policy_)); | 47 management_policy_)); |
| 48 |
| 49 (new extensions::ContentScriptsHandler)->Register(); |
| 44 } | 50 } |
| 45 | 51 |
| 46 virtual void TearDown() OVERRIDE { | 52 virtual void TearDown() OVERRIDE { |
| 47 handler_.reset(); | 53 handler_.reset(); |
| 48 profile_.reset(); | 54 profile_.reset(); |
| 49 // Execute any pending deletion tasks. | 55 // Execute any pending deletion tasks. |
| 50 message_loop_.RunUntilIdle(); | 56 message_loop_.RunUntilIdle(); |
| 57 extensions::ManifestHandler::ClearRegistryForTesting(); |
| 58 testing::Test::TearDown(); |
| 51 } | 59 } |
| 52 | 60 |
| 53 static DictionaryValue* DeserializeJSONTestData(const base::FilePath& path, | 61 static DictionaryValue* DeserializeJSONTestData(const base::FilePath& path, |
| 54 std::string *error) { | 62 std::string *error) { |
| 55 Value* value; | 63 Value* value; |
| 56 | 64 |
| 57 JSONFileValueSerializer serializer(path); | 65 JSONFileValueSerializer serializer(path); |
| 58 value = serializer.Deserialize(NULL, error); | 66 value = serializer.Deserialize(NULL, error); |
| 59 | 67 |
| 60 return static_cast<DictionaryValue*>(value); | 68 return static_cast<DictionaryValue*>(value); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 268 |
| 261 scoped_ptr<DictionaryValue> extension_details( | 269 scoped_ptr<DictionaryValue> extension_details( |
| 262 CreateExtensionDetailViewFromPath( | 270 CreateExtensionDetailViewFromPath( |
| 263 extension_path, pages, Manifest::UNPACKED)); | 271 extension_path, pages, Manifest::UNPACKED)); |
| 264 | 272 |
| 265 base::FilePath::StringType ui_path; | 273 base::FilePath::StringType ui_path; |
| 266 | 274 |
| 267 EXPECT_TRUE(extension_details->GetString("path", &ui_path)); | 275 EXPECT_TRUE(extension_details->GetString("path", &ui_path)); |
| 268 EXPECT_EQ(extension_path, base::FilePath(ui_path)); | 276 EXPECT_EQ(extension_path, base::FilePath(ui_path)); |
| 269 } | 277 } |
| OLD | NEW |