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/strings/string_split.h" | 7 #include "base/strings/string_split.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/extensions/api/test/test_api.h" | 11 #include "chrome/browser/extensions/api/test/test_api.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_system.h" | 13 #include "chrome/browser/extensions/extension_system.h" |
14 #include "chrome/browser/extensions/unpacked_installer.h" | 14 #include "chrome/browser/extensions/unpacked_installer.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/extensions/application_launch.h" | 17 #include "chrome/browser/ui/extensions/application_launch.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
21 #include "extensions/common/extension.h" | 21 #include "extensions/common/extension.h" |
| 22 #include "extensions/common/extension_set.h" |
22 #include "net/base/escape.h" | 23 #include "net/base/escape.h" |
23 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
24 #include "net/test/embedded_test_server/embedded_test_server.h" | 25 #include "net/test/embedded_test_server/embedded_test_server.h" |
25 #include "net/test/embedded_test_server/http_request.h" | 26 #include "net/test/embedded_test_server/http_request.h" |
26 #include "net/test/embedded_test_server/http_response.h" | 27 #include "net/test/embedded_test_server/http_response.h" |
27 #include "net/test/spawned_test_server/spawned_test_server.h" | 28 #include "net/test/spawned_test_server/spawned_test_server.h" |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 const char kTestCustomArg[] = "customArg"; | 32 const char kTestCustomArg[] = "customArg"; |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 | 387 |
387 return true; | 388 return true; |
388 } | 389 } |
389 | 390 |
390 // Test that exactly one extension is loaded, and return it. | 391 // Test that exactly one extension is loaded, and return it. |
391 const extensions::Extension* ExtensionApiTest::GetSingleLoadedExtension() { | 392 const extensions::Extension* ExtensionApiTest::GetSingleLoadedExtension() { |
392 ExtensionService* service = extensions::ExtensionSystem::Get( | 393 ExtensionService* service = extensions::ExtensionSystem::Get( |
393 browser()->profile())->extension_service(); | 394 browser()->profile())->extension_service(); |
394 | 395 |
395 const extensions::Extension* extension = NULL; | 396 const extensions::Extension* extension = NULL; |
396 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 397 for (extensions::ExtensionSet::const_iterator it = |
| 398 service->extensions()->begin(); |
397 it != service->extensions()->end(); ++it) { | 399 it != service->extensions()->end(); ++it) { |
398 // Ignore any component extensions. They are automatically loaded into all | 400 // Ignore any component extensions. They are automatically loaded into all |
399 // profiles and aren't the extension we're looking for here. | 401 // profiles and aren't the extension we're looking for here. |
400 if ((*it)->location() == extensions::Manifest::COMPONENT) | 402 if ((*it)->location() == extensions::Manifest::COMPONENT) |
401 continue; | 403 continue; |
402 | 404 |
403 if (extension != NULL) { | 405 if (extension != NULL) { |
404 // TODO(yoz): this is misleading; it counts component extensions. | 406 // TODO(yoz): this is misleading; it counts component extensions. |
405 message_ = base::StringPrintf( | 407 message_ = base::StringPrintf( |
406 "Expected only one extension to be present. Found %u.", | 408 "Expected only one extension to be present. Found %u.", |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 test_config_->SetInteger(kSpawnedTestServerPort, | 459 test_config_->SetInteger(kSpawnedTestServerPort, |
458 test_server()->host_port_pair().port()); | 460 test_server()->host_port_pair().port()); |
459 | 461 |
460 return true; | 462 return true; |
461 } | 463 } |
462 | 464 |
463 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { | 465 void ExtensionApiTest::SetUpCommandLine(CommandLine* command_line) { |
464 ExtensionBrowserTest::SetUpCommandLine(command_line); | 466 ExtensionBrowserTest::SetUpCommandLine(command_line); |
465 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); | 467 test_data_dir_ = test_data_dir_.AppendASCII("api_test"); |
466 } | 468 } |
OLD | NEW |