| 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 "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/browser/web_applications/web_app.h" | |
| 14 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 const char kTestServerPort[] = "testServer.port"; | 20 const char kTestServerPort[] = "testServer.port"; |
| 22 const char kTestDataDirectory[] = "testDataDirectory"; | 21 const char kTestDataDirectory[] = "testDataDirectory"; |
| 23 | 22 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 const std::string& page_url) { | 154 const std::string& page_url) { |
| 156 DCHECK(!page_url.empty()) << "Argument page_url is required."; | 155 DCHECK(!page_url.empty()) << "Argument page_url is required."; |
| 157 return RunExtensionTestImpl(extension_name, page_url, kFlagEnableIncognito); | 156 return RunExtensionTestImpl(extension_name, page_url, kFlagEnableIncognito); |
| 158 } | 157 } |
| 159 | 158 |
| 160 bool ExtensionApiTest::RunPageTest(const std::string& page_url) { | 159 bool ExtensionApiTest::RunPageTest(const std::string& page_url) { |
| 161 return RunExtensionSubtest("", page_url); | 160 return RunExtensionSubtest("", page_url); |
| 162 } | 161 } |
| 163 | 162 |
| 164 bool ExtensionApiTest::RunPlatformAppTest(const char* extension_name) { | 163 bool ExtensionApiTest::RunPlatformAppTest(const char* extension_name) { |
| 165 web_app::SetDisableShortcutCreationForTests(true); | |
| 166 return RunExtensionTestImpl(extension_name, "", kFlagLaunchAppShell); | 164 return RunExtensionTestImpl(extension_name, "", kFlagLaunchAppShell); |
| 167 } | 165 } |
| 168 | 166 |
| 169 // Load |extension_name| extension and/or |page_url| and wait for | 167 // Load |extension_name| extension and/or |page_url| and wait for |
| 170 // PASSED or FAILED notification. | 168 // PASSED or FAILED notification. |
| 171 bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, | 169 bool ExtensionApiTest::RunExtensionTestImpl(const char* extension_name, |
| 172 const std::string& page_url, | 170 const std::string& page_url, |
| 173 int flags) { | 171 int flags) { |
| 174 bool enable_incognito = (flags & kFlagEnableIncognito) != 0; | 172 bool enable_incognito = (flags & kFlagEnableIncognito) != 0; |
| 175 bool enable_fileaccess = (flags & kFlagEnableFileAccess) != 0; | 173 bool enable_fileaccess = (flags & kFlagEnableFileAccess) != 0; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 test_config_->SetInteger(kTestServerPort, | 266 test_config_->SetInteger(kTestServerPort, |
| 269 test_server()->host_port_pair().port()); | 267 test_server()->host_port_pair().port()); |
| 270 | 268 |
| 271 return true; | 269 return true; |
| 272 } | 270 } |
| 273 | 271 |
| 274 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { | 272 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { |
| 275 ExtensionBrowserTest::SetUpCommandLine(command_line); | 273 ExtensionBrowserTest::SetUpCommandLine(command_line); |
| 276 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); | 274 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); |
| 277 } | 275 } |
| OLD | NEW |