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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #endif | 52 #endif |
53 | 53 |
54 using extensions::Extension; | 54 using extensions::Extension; |
55 using extensions::ExtensionCreator; | 55 using extensions::ExtensionCreator; |
56 using extensions::FeatureSwitch; | 56 using extensions::FeatureSwitch; |
57 using extensions::Manifest; | 57 using extensions::Manifest; |
58 | 58 |
59 ExtensionBrowserTest::ExtensionBrowserTest() | 59 ExtensionBrowserTest::ExtensionBrowserTest() |
60 : loaded_(false), | 60 : loaded_(false), |
61 installed_(false), | 61 installed_(false), |
62 #if defined(OS_CHROMEOS) | |
63 set_chromeos_user_(true), | |
64 #endif | |
65 // Default channel is STABLE but override with UNKNOWN so that unlaunched | 62 // Default channel is STABLE but override with UNKNOWN so that unlaunched |
66 // or incomplete APIs can write tests. | 63 // or incomplete APIs can write tests. |
67 current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN), | 64 current_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN), |
68 override_prompt_for_external_extensions_( | 65 override_prompt_for_external_extensions_( |
69 FeatureSwitch::prompt_for_external_extensions(), | 66 FeatureSwitch::prompt_for_external_extensions(), |
70 false), | 67 false), |
71 profile_(NULL) { | 68 profile_(NULL) { |
72 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 69 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
73 } | 70 } |
74 | 71 |
(...skipping 25 matching lines...) Expand all Loading... |
100 } | 97 } |
101 | 98 |
102 void ExtensionBrowserTest::SetUp() { | 99 void ExtensionBrowserTest::SetUp() { |
103 test_extension_cache_.reset(new extensions::ExtensionCacheFake()); | 100 test_extension_cache_.reset(new extensions::ExtensionCacheFake()); |
104 InProcessBrowserTest::SetUp(); | 101 InProcessBrowserTest::SetUp(); |
105 } | 102 } |
106 | 103 |
107 void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) { | 104 void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) { |
108 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); | 105 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); |
109 test_data_dir_ = test_data_dir_.AppendASCII("extensions"); | 106 test_data_dir_ = test_data_dir_.AppendASCII("extensions"); |
110 observer_.reset(new ExtensionTestNotificationObserver(browser())); | |
111 | |
112 #if defined(OS_CHROMEOS) | |
113 if (set_chromeos_user_) { | |
114 // This makes sure that we create the Default profile first, with no | |
115 // ExtensionService and then the real profile with one, as we do when | |
116 // running on chromeos. | |
117 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, | |
118 "TestUser@gmail.com"); | |
119 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | |
120 } | |
121 #endif | |
122 } | 107 } |
123 | 108 |
124 void ExtensionBrowserTest::SetUpOnMainThread() { | 109 void ExtensionBrowserTest::SetUpOnMainThread() { |
125 InProcessBrowserTest::SetUpOnMainThread(); | 110 InProcessBrowserTest::SetUpOnMainThread(); |
126 observer_.reset(new ExtensionTestNotificationObserver(browser())); | 111 observer_.reset(new ExtensionTestNotificationObserver(browser())); |
127 } | 112 } |
128 | 113 |
129 const Extension* ExtensionBrowserTest::LoadExtension( | 114 const Extension* ExtensionBrowserTest::LoadExtension( |
130 const base::FilePath& path) { | 115 const base::FilePath& path) { |
131 return LoadExtensionWithFlags(path, kFlagEnableFileAccess); | 116 return LoadExtensionWithFlags(path, kFlagEnableFileAccess); |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( | 601 return extensions::browsertest_util::ExecuteScriptInBackgroundPage( |
617 profile(), extension_id, script); | 602 profile(), extension_id, script); |
618 } | 603 } |
619 | 604 |
620 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( | 605 bool ExtensionBrowserTest::ExecuteScriptInBackgroundPageNoWait( |
621 const std::string& extension_id, | 606 const std::string& extension_id, |
622 const std::string& script) { | 607 const std::string& script) { |
623 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( | 608 return extensions::browsertest_util::ExecuteScriptInBackgroundPageNoWait( |
624 profile(), extension_id, script); | 609 profile(), extension_id, script); |
625 } | 610 } |
OLD | NEW |