OLD | NEW |
---|---|
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 "chrome/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/memory/scoped_temp_dir.h" | |
14 #include "chrome/browser/extensions/crx_installer.h" | 15 #include "chrome/browser/extensions/crx_installer.h" |
15 #include "chrome/browser/extensions/extension_creator.h" | 16 #include "chrome/browser/extensions/extension_creator.h" |
16 #include "chrome/browser/extensions/extension_error_reporter.h" | 17 #include "chrome/browser/extensions/extension_error_reporter.h" |
17 #include "chrome/browser/extensions/extension_host.h" | 18 #include "chrome/browser/extensions/extension_host.h" |
18 #include "chrome/browser/extensions/extension_install_ui.h" | 19 #include "chrome/browser/extensions/extension_install_ui.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
22 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
23 #include "chrome/browser/ui/omnibox/location_bar.h" | 24 #include "chrome/browser/ui/omnibox/location_bar.h" |
24 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/test/ui_test_utils.h" | 27 #include "chrome/test/ui_test_utils.h" |
27 #include "content/common/notification_registrar.h" | 28 #include "content/common/notification_registrar.h" |
28 #include "content/common/notification_service.h" | 29 #include "content/common/notification_service.h" |
29 #include "content/common/notification_type.h" | 30 #include "content/common/notification_type.h" |
30 | 31 |
31 ExtensionBrowserTest::ExtensionBrowserTest() | 32 ExtensionBrowserTest::ExtensionBrowserTest() |
32 : loaded_(false), | 33 : loaded_(false), |
33 installed_(false), | 34 installed_(false), |
34 extension_installs_observed_(0), | 35 extension_installs_observed_(0), |
35 target_page_action_count_(-1), | 36 target_page_action_count_(-1), |
36 target_visible_page_action_count_(-1) { | 37 target_visible_page_action_count_(-1) { |
38 DCHECK(temp_dir_.CreateUniqueTempDir()); | |
Paweł Hajdan Jr.
2011/04/11 18:16:53
Oops, two things are wrong about that:
1) DCHECK
Mike West
2011/04/12 07:04:04
Right, I kinda knew that DCHECK was wrong, but I d
Paweł Hajdan Jr.
2011/04/12 08:32:02
EXPECT_TRUE in ctor is fine for me. BrowserTest ha
| |
37 } | 39 } |
38 | 40 |
39 void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 41 void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
40 // This enables DOM automation for tab contentses. | 42 // This enables DOM automation for tab contentses. |
41 EnableDOMAutomation(); | 43 EnableDOMAutomation(); |
42 | 44 |
43 // This enables it for extension hosts. | 45 // This enables it for extension hosts. |
44 ExtensionHost::EnableDOMAutomation(); | 46 ExtensionHost::EnableDOMAutomation(); |
45 | 47 |
46 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); | 48 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 &manifest)) | 121 &manifest)) |
120 return false; | 122 return false; |
121 | 123 |
122 service->LoadComponentExtension( | 124 service->LoadComponentExtension( |
123 ExtensionService::ComponentExtensionInfo(manifest, path)); | 125 ExtensionService::ComponentExtensionInfo(manifest, path)); |
124 | 126 |
125 return true; | 127 return true; |
126 } | 128 } |
127 | 129 |
128 FilePath ExtensionBrowserTest::PackExtension(const FilePath& dir_path) { | 130 FilePath ExtensionBrowserTest::PackExtension(const FilePath& dir_path) { |
129 FilePath crx_path; | 131 FilePath crx_path = temp_dir_.path().AppendASCII("temp.crx"); |
130 if (!PathService::Get(base::DIR_TEMP, &crx_path)) { | |
131 ADD_FAILURE() << "Failed to get DIR_TEMP from PathService."; | |
132 return FilePath(); | |
133 } | |
134 crx_path = crx_path.AppendASCII("temp.crx"); | |
135 if (!file_util::Delete(crx_path, false)) { | 132 if (!file_util::Delete(crx_path, false)) { |
136 ADD_FAILURE() << "Failed to delete crx: " << crx_path.value(); | 133 ADD_FAILURE() << "Failed to delete crx: " << crx_path.value(); |
137 return FilePath(); | 134 return FilePath(); |
138 } | 135 } |
139 | 136 |
140 FilePath pem_path = crx_path.DirName().AppendASCII("temp.pem"); | 137 FilePath pem_path = crx_path.DirName().AppendASCII("temp.pem"); |
141 if (!file_util::Delete(pem_path, false)) { | 138 if (!file_util::Delete(pem_path, false)) { |
142 ADD_FAILURE() << "Failed to delete pem: " << pem_path.value(); | 139 ADD_FAILURE() << "Failed to delete pem: " << pem_path.value(); |
143 return FilePath(); | 140 return FilePath(); |
144 } | 141 } |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 MessageLoopForUI::current()->Quit(); | 438 MessageLoopForUI::current()->Quit(); |
442 } | 439 } |
443 break; | 440 break; |
444 } | 441 } |
445 | 442 |
446 default: | 443 default: |
447 NOTREACHED(); | 444 NOTREACHED(); |
448 break; | 445 break; |
449 } | 446 } |
450 } | 447 } |
OLD | NEW |