| 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/extension_unittest.h" | |
| 17 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | |
| 18 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
| 20 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 20 |
| 23 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
| 24 #include "chrome/browser/chromeos/login/user_manager.h" | 22 #include "chrome/browser/chromeos/login/user_manager.h" |
| 25 #include "chrome/browser/chromeos/settings/cros_settings.h" | 23 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 26 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 24 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 27 #endif | 25 #endif |
| 28 | 26 |
| 29 using extensions::Extension; | 27 using extensions::Extension; |
| 30 using extensions::Manifest; | 28 using extensions::Manifest; |
| 31 | 29 |
| 32 class ExtensionUITest : public extensions::ExtensionTest { | 30 class ExtensionUITest : public testing::Test { |
| 33 public: | 31 public: |
| 34 ExtensionUITest() | 32 ExtensionUITest() |
| 35 : ui_thread_(content::BrowserThread::UI, &message_loop_), | 33 : ui_thread_(content::BrowserThread::UI, &message_loop_), |
| 36 file_thread_(content::BrowserThread::FILE, &message_loop_) {} | 34 file_thread_(content::BrowserThread::FILE, &message_loop_) {} |
| 37 | 35 |
| 38 protected: | 36 protected: |
| 39 virtual void SetUp() OVERRIDE { | 37 virtual void SetUp() OVERRIDE { |
| 40 ExtensionTest::SetUp(); | |
| 41 | |
| 42 // Create an ExtensionService and ManagementPolicy to inject into the | 38 // Create an ExtensionService and ManagementPolicy to inject into the |
| 43 // ExtensionSettingsHandler. | 39 // ExtensionSettingsHandler. |
| 44 profile_.reset(new TestingProfile()); | 40 profile_.reset(new TestingProfile()); |
| 45 extensions::TestExtensionSystem* system = | 41 extensions::TestExtensionSystem* system = |
| 46 static_cast<extensions::TestExtensionSystem*>( | 42 static_cast<extensions::TestExtensionSystem*>( |
| 47 extensions::ExtensionSystem::Get(profile_.get())); | 43 extensions::ExtensionSystem::Get(profile_.get())); |
| 48 extension_service_ = system->CreateExtensionService( | 44 extension_service_ = system->CreateExtensionService( |
| 49 CommandLine::ForCurrentProcess(), base::FilePath(), false); | 45 CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 50 management_policy_ = system->management_policy(); | 46 management_policy_ = system->management_policy(); |
| 51 | 47 |
| 52 handler_.reset(new ExtensionSettingsHandler(extension_service_, | 48 handler_.reset(new ExtensionSettingsHandler(extension_service_, |
| 53 management_policy_)); | 49 management_policy_)); |
| 54 | |
| 55 (new extensions::ContentScriptsHandler)->Register(); | |
| 56 } | 50 } |
| 57 | 51 |
| 58 virtual void TearDown() OVERRIDE { | 52 virtual void TearDown() OVERRIDE { |
| 59 handler_.reset(); | 53 handler_.reset(); |
| 60 profile_.reset(); | 54 profile_.reset(); |
| 61 // Execute any pending deletion tasks. | 55 // Execute any pending deletion tasks. |
| 62 message_loop_.RunUntilIdle(); | 56 message_loop_.RunUntilIdle(); |
| 63 ExtensionTest::TearDown(); | |
| 64 } | 57 } |
| 65 | 58 |
| 66 static DictionaryValue* DeserializeJSONTestData(const base::FilePath& path, | 59 static DictionaryValue* DeserializeJSONTestData(const base::FilePath& path, |
| 67 std::string *error) { | 60 std::string *error) { |
| 68 Value* value; | 61 Value* value; |
| 69 | 62 |
| 70 JSONFileValueSerializer serializer(path); | 63 JSONFileValueSerializer serializer(path); |
| 71 value = serializer.Deserialize(NULL, error); | 64 value = serializer.Deserialize(NULL, error); |
| 72 | 65 |
| 73 return static_cast<DictionaryValue*>(value); | 66 return static_cast<DictionaryValue*>(value); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 272 |
| 280 scoped_ptr<DictionaryValue> extension_details( | 273 scoped_ptr<DictionaryValue> extension_details( |
| 281 CreateExtensionDetailViewFromPath( | 274 CreateExtensionDetailViewFromPath( |
| 282 extension_path, pages, Manifest::UNPACKED)); | 275 extension_path, pages, Manifest::UNPACKED)); |
| 283 | 276 |
| 284 base::FilePath::StringType ui_path; | 277 base::FilePath::StringType ui_path; |
| 285 | 278 |
| 286 EXPECT_TRUE(extension_details->GetString("path", &ui_path)); | 279 EXPECT_TRUE(extension_details->GetString("path", &ui_path)); |
| 287 EXPECT_EQ(extension_path, base::FilePath(ui_path)); | 280 EXPECT_EQ(extension_path, base::FilePath(ui_path)); |
| 288 } | 281 } |
| OLD | NEW |