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_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/extensions/extension_test_api.h" | 10 #include "chrome/browser/extensions/extension_test_api.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 const char kTestServerPort[] = "testServer.port"; | 20 const char kTestServerPort[] = "testServer.port"; |
| 21 const char kTestDataDirectory[] = "testDataDirectory"; |
21 | 22 |
22 }; // namespace | 23 }; // namespace |
23 | 24 |
24 ExtensionApiTest::ExtensionApiTest() {} | 25 ExtensionApiTest::ExtensionApiTest() {} |
25 | 26 |
26 ExtensionApiTest::~ExtensionApiTest() {} | 27 ExtensionApiTest::~ExtensionApiTest() {} |
27 | 28 |
28 ExtensionApiTest::ResultCatcher::ResultCatcher() | 29 ExtensionApiTest::ResultCatcher::ResultCatcher() |
29 : profile_restriction_(NULL), | 30 : profile_restriction_(NULL), |
30 waiting_(false) { | 31 waiting_(false) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 break; | 87 break; |
87 | 88 |
88 default: | 89 default: |
89 NOTREACHED(); | 90 NOTREACHED(); |
90 } | 91 } |
91 } | 92 } |
92 | 93 |
93 void ExtensionApiTest::SetUpInProcessBrowserTestFixture() { | 94 void ExtensionApiTest::SetUpInProcessBrowserTestFixture() { |
94 DCHECK(!test_config_.get()) << "Previous test did not clear config state."; | 95 DCHECK(!test_config_.get()) << "Previous test did not clear config state."; |
95 test_config_.reset(new DictionaryValue()); | 96 test_config_.reset(new DictionaryValue()); |
| 97 test_config_->SetString(kTestDataDirectory, |
| 98 net::FilePathToFileURL(test_data_dir_).spec()); |
96 ExtensionTestGetConfigFunction::set_test_config_state(test_config_.get()); | 99 ExtensionTestGetConfigFunction::set_test_config_state(test_config_.get()); |
97 } | 100 } |
98 | 101 |
99 void ExtensionApiTest::TearDownInProcessBrowserTestFixture() { | 102 void ExtensionApiTest::TearDownInProcessBrowserTestFixture() { |
100 ExtensionTestGetConfigFunction::set_test_config_state(NULL); | 103 ExtensionTestGetConfigFunction::set_test_config_state(NULL); |
101 test_config_.reset(NULL); | 104 test_config_.reset(NULL); |
102 } | 105 } |
103 | 106 |
104 bool ExtensionApiTest::RunExtensionTest(const char* extension_name) { | 107 bool ExtensionApiTest::RunExtensionTest(const char* extension_name) { |
105 return RunExtensionTestImpl(extension_name, "", false, true, false); | 108 return RunExtensionTestImpl(extension_name, "", false, true, false); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 return NULL; | 229 return NULL; |
227 } | 230 } |
228 return extension; | 231 return extension; |
229 } | 232 } |
230 | 233 |
231 bool ExtensionApiTest::StartTestServer() { | 234 bool ExtensionApiTest::StartTestServer() { |
232 if (!test_server()->Start()) | 235 if (!test_server()->Start()) |
233 return false; | 236 return false; |
234 | 237 |
235 // Build a dictionary of values that tests can use to build URLs that | 238 // Build a dictionary of values that tests can use to build URLs that |
236 // access the test server. Tests can see these values using the extension | 239 // access the test server and local file system. Tests can see these values |
237 // API function chrome.test.getConfig(). | 240 // using the extension API function chrome.test.getConfig(). |
238 test_config_->SetInteger(kTestServerPort, | 241 test_config_->SetInteger(kTestServerPort, |
239 test_server()->host_port_pair().port()); | 242 test_server()->host_port_pair().port()); |
240 | 243 |
241 return true; | 244 return true; |
242 } | 245 } |
243 | 246 |
244 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { | 247 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { |
245 ExtensionBrowserTest::SetUpCommandLine(command_line); | 248 ExtensionBrowserTest::SetUpCommandLine(command_line); |
246 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); | 249 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); |
247 } | 250 } |
OLD | NEW |