| 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_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_util.h" | 10 #include "base/file_util.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/extensions/extension_util.h" | 27 #include "chrome/browser/extensions/extension_util.h" |
| 28 #include "chrome/browser/extensions/unpacked_installer.h" | 28 #include "chrome/browser/extensions/unpacked_installer.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
| 31 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
| 32 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
| 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 34 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_paths.h" |
| 35 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/chrome_version_info.h" | 36 #include "chrome/common/chrome_version_info.h" |
| 37 #include "chrome/common/extensions/extension_set.h" | |
| 38 #include "chrome/test/base/ui_test_utils.h" | 37 #include "chrome/test/base/ui_test_utils.h" |
| 39 #include "content/public/browser/navigation_controller.h" | 38 #include "content/public/browser/navigation_controller.h" |
| 40 #include "content/public/browser/navigation_entry.h" | 39 #include "content/public/browser/navigation_entry.h" |
| 41 #include "content/public/browser/notification_registrar.h" | 40 #include "content/public/browser/notification_registrar.h" |
| 42 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 43 #include "content/public/browser/render_view_host.h" | 42 #include "content/public/browser/render_view_host.h" |
| 44 #include "content/public/test/browser_test_utils.h" | 43 #include "content/public/test/browser_test_utils.h" |
| 45 #include "extensions/common/constants.h" | 44 #include "extensions/common/constants.h" |
| 45 #include "extensions/common/extension_set.h" |
| 46 #include "sync/api/string_ordinal.h" | 46 #include "sync/api/string_ordinal.h" |
| 47 | 47 |
| 48 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
| 49 #include "chromeos/chromeos_switches.h" | 49 #include "chromeos/chromeos_switches.h" |
| 50 #endif | 50 #endif |
| 51 | 51 |
| 52 using extensions::Extension; | 52 using extensions::Extension; |
| 53 using extensions::ExtensionCreator; | 53 using extensions::ExtensionCreator; |
| 54 using extensions::FeatureSwitch; | 54 using extensions::FeatureSwitch; |
| 55 using extensions::Manifest; | 55 using extensions::Manifest; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 73 if (browser()) | 73 if (browser()) |
| 74 profile_ = browser()->profile(); | 74 profile_ = browser()->profile(); |
| 75 else | 75 else |
| 76 profile_ = ProfileManager::GetDefaultProfile(); | 76 profile_ = ProfileManager::GetDefaultProfile(); |
| 77 } | 77 } |
| 78 return profile_; | 78 return profile_; |
| 79 } | 79 } |
| 80 | 80 |
| 81 // static | 81 // static |
| 82 const Extension* ExtensionBrowserTest::GetExtensionByPath( | 82 const Extension* ExtensionBrowserTest::GetExtensionByPath( |
| 83 const ExtensionSet* extensions, const base::FilePath& path) { | 83 const extensions::ExtensionSet* extensions, const base::FilePath& path) { |
| 84 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); | 84 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); |
| 85 EXPECT_TRUE(!extension_path.empty()); | 85 EXPECT_TRUE(!extension_path.empty()); |
| 86 for (ExtensionSet::const_iterator iter = extensions->begin(); | 86 for (extensions::ExtensionSet::const_iterator iter = extensions->begin(); |
| 87 iter != extensions->end(); ++iter) { | 87 iter != extensions->end(); ++iter) { |
| 88 if ((*iter)->path() == extension_path) { | 88 if ((*iter)->path() == extension_path) { |
| 89 return iter->get(); | 89 return iter->get(); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 return NULL; | 92 return NULL; |
| 93 } | 93 } |
| 94 | 94 |
| 95 void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 95 void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
| 96 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); | 96 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 observer_->Wait(); | 446 observer_->Wait(); |
| 447 } | 447 } |
| 448 | 448 |
| 449 size_t num_after = service->extensions()->size(); | 449 size_t num_after = service->extensions()->size(); |
| 450 EXPECT_EQ(num_before + expected_change, num_after); | 450 EXPECT_EQ(num_before + expected_change, num_after); |
| 451 if (num_before + expected_change != num_after) { | 451 if (num_before + expected_change != num_after) { |
| 452 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) | 452 VLOG(1) << "Num extensions before: " << base::IntToString(num_before) |
| 453 << " num after: " << base::IntToString(num_after) | 453 << " num after: " << base::IntToString(num_after) |
| 454 << " Installed extensions follow:"; | 454 << " Installed extensions follow:"; |
| 455 | 455 |
| 456 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 456 for (extensions::ExtensionSet::const_iterator it = |
| 457 service->extensions()->begin(); |
| 457 it != service->extensions()->end(); ++it) | 458 it != service->extensions()->end(); ++it) |
| 458 VLOG(1) << " " << (*it)->id(); | 459 VLOG(1) << " " << (*it)->id(); |
| 459 | 460 |
| 460 VLOG(1) << "Errors follow:"; | 461 VLOG(1) << "Errors follow:"; |
| 461 const std::vector<string16>* errors = | 462 const std::vector<string16>* errors = |
| 462 ExtensionErrorReporter::GetInstance()->GetErrors(); | 463 ExtensionErrorReporter::GetInstance()->GetErrors(); |
| 463 for (std::vector<string16>::const_iterator iter = errors->begin(); | 464 for (std::vector<string16>::const_iterator iter = errors->begin(); |
| 464 iter != errors->end(); ++iter) | 465 iter != errors->end(); ++iter) |
| 465 VLOG(1) << *iter; | 466 VLOG(1) << *iter; |
| 466 | 467 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 EXPECT_EQ(expected_hosts, num_hosts); | 578 EXPECT_EQ(expected_hosts, num_hosts); |
| 578 return host; | 579 return host; |
| 579 } | 580 } |
| 580 | 581 |
| 581 std::string ExtensionBrowserTest::ExecuteScriptInBackgroundPage( | 582 std::string ExtensionBrowserTest::ExecuteScriptInBackgroundPage( |
| 582 const std::string& extension_id, | 583 const std::string& extension_id, |
| 583 const std::string& script) { | 584 const std::string& script) { |
| 584 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 585 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
| 585 profile(), extension_id, script); | 586 profile(), extension_id, script); |
| 586 } | 587 } |
| OLD | NEW |