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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 public: | 31 public: |
32 ExtensionStartupTestBase() : enable_extensions_(false) { | 32 ExtensionStartupTestBase() : enable_extensions_(false) { |
33 num_expected_extensions_ = 3; | 33 num_expected_extensions_ = 3; |
34 } | 34 } |
35 | 35 |
36 protected: | 36 protected: |
37 // InProcessBrowserTest | 37 // InProcessBrowserTest |
38 virtual void SetUpCommandLine(CommandLine* command_line) { | 38 virtual void SetUpCommandLine(CommandLine* command_line) { |
39 EnableDOMAutomation(); | 39 EnableDOMAutomation(); |
40 | 40 |
| 41 if (!enable_extensions_) |
| 42 command_line->AppendSwitch(switches::kDisableExtensions); |
| 43 |
| 44 if (!load_extensions_.empty()) { |
| 45 FilePath::StringType paths = JoinString(load_extensions_, ','); |
| 46 command_line->AppendSwitchNative(switches::kLoadExtension, |
| 47 paths); |
| 48 command_line->AppendSwitch(switches::kDisableExtensionsFileAccessCheck); |
| 49 } |
| 50 } |
| 51 |
| 52 virtual bool SetUpUserDataDirectory() { |
41 FilePath profile_dir; | 53 FilePath profile_dir; |
42 PathService::Get(chrome::DIR_USER_DATA, &profile_dir); | 54 PathService::Get(chrome::DIR_USER_DATA, &profile_dir); |
43 profile_dir = profile_dir.AppendASCII("Default"); | 55 profile_dir = profile_dir.AppendASCII("Default"); |
44 file_util::CreateDirectory(profile_dir); | 56 file_util::CreateDirectory(profile_dir); |
45 | 57 |
46 preferences_file_ = profile_dir.AppendASCII("Preferences"); | 58 preferences_file_ = profile_dir.AppendASCII("Preferences"); |
47 user_scripts_dir_ = profile_dir.AppendASCII("User Scripts"); | 59 user_scripts_dir_ = profile_dir.AppendASCII("User Scripts"); |
48 extensions_dir_ = profile_dir.AppendASCII("Extensions"); | 60 extensions_dir_ = profile_dir.AppendASCII("Extensions"); |
49 | 61 |
50 if (enable_extensions_) { | 62 if (enable_extensions_ && load_extensions_.empty()) { |
51 if (load_extensions_.empty()) { | 63 FilePath src_dir; |
52 FilePath src_dir; | 64 PathService::Get(chrome::DIR_TEST_DATA, &src_dir); |
53 PathService::Get(chrome::DIR_TEST_DATA, &src_dir); | 65 src_dir = src_dir.AppendASCII("extensions").AppendASCII("good"); |
54 src_dir = src_dir.AppendASCII("extensions").AppendASCII("good"); | |
55 | 66 |
56 file_util::CopyFile(src_dir.AppendASCII("Preferences"), | 67 file_util::CopyFile(src_dir.AppendASCII("Preferences"), |
57 preferences_file_); | 68 preferences_file_); |
58 file_util::CopyDirectory(src_dir.AppendASCII("Extensions"), | 69 file_util::CopyDirectory(src_dir.AppendASCII("Extensions"), |
59 profile_dir, true); // recursive | 70 profile_dir, true); // recursive |
60 } | |
61 } else { | |
62 command_line->AppendSwitch(switches::kDisableExtensions); | |
63 } | 71 } |
64 | 72 return true; |
65 if (!load_extensions_.empty()) { | |
66 FilePath::StringType paths = JoinString(load_extensions_, ','); | |
67 command_line->AppendSwitchNative(switches::kLoadExtension, | |
68 paths); | |
69 command_line->AppendSwitch(switches::kDisableExtensionsFileAccessCheck); | |
70 } | |
71 } | 73 } |
72 | 74 |
73 virtual void TearDown() { | 75 virtual void TearDown() { |
74 EXPECT_TRUE(file_util::Delete(preferences_file_, false)); | 76 EXPECT_TRUE(file_util::Delete(preferences_file_, false)); |
75 | 77 |
76 // TODO(phajdan.jr): Check return values of the functions below, carefully. | 78 // TODO(phajdan.jr): Check return values of the functions below, carefully. |
77 file_util::Delete(user_scripts_dir_, true); | 79 file_util::Delete(user_scripts_dir_, true); |
78 file_util::Delete(extensions_dir_, true); | 80 file_util::Delete(extensions_dir_, true); |
79 | 81 |
80 InProcessBrowserTest::TearDown(); | 82 InProcessBrowserTest::TearDown(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 .AppendASCII("extensions") | 259 .AppendASCII("extensions") |
258 .AppendASCII("app2"); | 260 .AppendASCII("app2"); |
259 load_extensions_.push_back(fourth_extension_path.value()); | 261 load_extensions_.push_back(fourth_extension_path.value()); |
260 } | 262 } |
261 }; | 263 }; |
262 | 264 |
263 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { | 265 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { |
264 WaitForServicesToStart(4, true); | 266 WaitForServicesToStart(4, true); |
265 TestInjection(true, true); | 267 TestInjection(true, true); |
266 } | 268 } |
OLD | NEW |