Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc

Issue 12212047: Linux/ChromeOS Chromium style checker cleanup, chrome/browser/extensions edition. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 26 matching lines...) Expand all
37 37
38 namespace extensions { 38 namespace extensions {
39 39
40 namespace { 40 namespace {
41 41
42 class WebstoreInstallListener : public WebstoreInstaller::Delegate { 42 class WebstoreInstallListener : public WebstoreInstaller::Delegate {
43 public: 43 public:
44 WebstoreInstallListener() 44 WebstoreInstallListener()
45 : received_failure_(false), received_success_(false), waiting_(false) {} 45 : received_failure_(false), received_success_(false), waiting_(false) {}
46 46
47 void OnExtensionInstallSuccess(const std::string& id) OVERRIDE { 47 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE {
48 received_success_ = true; 48 received_success_ = true;
49 id_ = id; 49 id_ = id;
50 50
51 if (waiting_) { 51 if (waiting_) {
52 waiting_ = false; 52 waiting_ = false;
53 MessageLoopForUI::current()->Quit(); 53 MessageLoopForUI::current()->Quit();
54 } 54 }
55 } 55 }
56 56
57 void OnExtensionInstallFailure( 57 virtual void OnExtensionInstallFailure(
58 const std::string& id, 58 const std::string& id,
59 const std::string& error, 59 const std::string& error,
60 WebstoreInstaller::FailureReason reason) OVERRIDE { 60 WebstoreInstaller::FailureReason reason) OVERRIDE {
61 received_failure_ = true; 61 received_failure_ = true;
62 id_ = id; 62 id_ = id;
63 error_ = error; 63 error_ = error;
64 64
65 if (waiting_) { 65 if (waiting_) {
66 waiting_ = false; 66 waiting_ = false;
67 MessageLoopForUI::current()->Quit(); 67 MessageLoopForUI::current()->Quit();
(...skipping 16 matching lines...) Expand all
84 bool waiting_; 84 bool waiting_;
85 std::string id_; 85 std::string id_;
86 std::string error_; 86 std::string error_;
87 }; 87 };
88 88
89 } // namespace 89 } // namespace
90 90
91 // A base class for tests below. 91 // A base class for tests below.
92 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { 92 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest {
93 public: 93 public:
94 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 94 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
95 ExtensionApiTest::SetUpCommandLine(command_line); 95 ExtensionApiTest::SetUpCommandLine(command_line);
96 command_line->AppendSwitchASCII( 96 command_line->AppendSwitchASCII(
97 switches::kAppsGalleryURL, 97 switches::kAppsGalleryURL,
98 "http://www.example.com/files/extensions/api_test"); 98 "http://www.example.com/files/extensions/api_test");
99 command_line->AppendSwitchASCII( 99 command_line->AppendSwitchASCII(
100 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); 100 switches::kAppsGalleryInstallAutoConfirmForTests, "accept");
101 } 101 }
102 102
103 void SetUpInProcessBrowserTestFixture() OVERRIDE { 103 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
104 // Start up the test server and get us ready for calling the install 104 // Start up the test server and get us ready for calling the install
105 // API functions. 105 // API functions.
106 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 106 host_resolver()->AddRule("www.example.com", "127.0.0.1");
107 ASSERT_TRUE(test_server()->Start()); 107 ASSERT_TRUE(test_server()->Start());
108 ExtensionInstallUI::DisableFailureUIForTests(); 108 ExtensionInstallUI::DisableFailureUIForTests();
109 109
110 ASSERT_TRUE(tmp_.CreateUniqueTempDirUnderPath(test_data_dir_)); 110 ASSERT_TRUE(tmp_.CreateUniqueTempDirUnderPath(test_data_dir_));
111 ASSERT_TRUE(file_util::CreateDirectory(tmp_.path())); 111 ASSERT_TRUE(file_util::CreateDirectory(tmp_.path()));
112 ASSERT_TRUE(file_util::CopyDirectory( 112 ASSERT_TRUE(file_util::CopyDirectory(
113 test_data_dir_.AppendASCII("webstore_private"), 113 test_data_dir_.AppendASCII("webstore_private"),
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 ExtensionService* service() { 149 ExtensionService* service() {
150 return browser()->profile()->GetExtensionService(); 150 return browser()->profile()->GetExtensionService();
151 } 151 }
152 152
153 base::ScopedTempDir tmp_; 153 base::ScopedTempDir tmp_;
154 }; 154 };
155 155
156 class ExtensionWebstorePrivateBundleTest 156 class ExtensionWebstorePrivateBundleTest
157 : public ExtensionWebstorePrivateApiTest { 157 : public ExtensionWebstorePrivateApiTest {
158 public: 158 public:
159 void SetUpInProcessBrowserTestFixture() OVERRIDE { 159 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
160 ExtensionWebstorePrivateApiTest::SetUpInProcessBrowserTestFixture(); 160 ExtensionWebstorePrivateApiTest::SetUpInProcessBrowserTestFixture();
161 161
162 // The test server needs to have already started, so setup the switch here 162 // The test server needs to have already started, so setup the switch here
163 // rather than in SetUpCommandLine. 163 // rather than in SetUpCommandLine.
164 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 164 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
165 switches::kAppsGalleryDownloadURL, 165 switches::kAppsGalleryDownloadURL,
166 GetTestServerURL("bundle/%s.crx").spec()); 166 GetTestServerURL("bundle/%s.crx").spec());
167 } 167 }
168 168
169 void TearDownInProcessBrowserTestFixture() OVERRIDE { 169 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE {
170 ExtensionWebstorePrivateApiTest::TearDownInProcessBrowserTestFixture(); 170 ExtensionWebstorePrivateApiTest::TearDownInProcessBrowserTestFixture();
171 for (size_t i = 0; i < test_crx_.size(); ++i) 171 for (size_t i = 0; i < test_crx_.size(); ++i)
172 ASSERT_TRUE(file_util::Delete(test_crx_[i], false)); 172 ASSERT_TRUE(file_util::Delete(test_crx_[i], false));
173 } 173 }
174 174
175 protected: 175 protected:
176 // Packs the |manifest| file into a CRX using |id|'s PEM key. 176 // Packs the |manifest| file into a CRX using |id|'s PEM key.
177 void PackCRX(const std::string& id, const std::string& manifest) { 177 void PackCRX(const std::string& id, const std::string& manifest) {
178 // Move the extension to a temporary directory. 178 // Move the extension to a temporary directory.
179 base::ScopedTempDir tmp; 179 base::ScopedTempDir tmp;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 217
218 test_crx_.push_back(crx_path); 218 test_crx_.push_back(crx_path);
219 } 219 }
220 220
221 private: 221 private:
222 std::vector<FilePath> test_crx_; 222 std::vector<FilePath> test_crx_;
223 }; 223 };
224 224
225 class ExtensionWebstoreGetWebGLStatusTest : public InProcessBrowserTest { 225 class ExtensionWebstoreGetWebGLStatusTest : public InProcessBrowserTest {
226 public: 226 public:
227 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 227 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
228 // In linux, we need to launch GPU process to decide if WebGL is allowed. 228 // In linux, we need to launch GPU process to decide if WebGL is allowed.
229 // Run it on top of osmesa to avoid bot driver issues. 229 // Run it on top of osmesa to avoid bot driver issues.
230 #if defined(OS_LINUX) 230 #if defined(OS_LINUX)
231 CHECK(test_launcher_utils::OverrideGLImplementation( 231 CHECK(test_launcher_utils::OverrideGLImplementation(
232 command_line, gfx::kGLImplementationOSMesaName)) << 232 command_line, gfx::kGLImplementationOSMesaName)) <<
233 "kUseGL must not be set multiple times!"; 233 "kUseGL must not be set multiple times!";
234 #endif 234 #endif
235 } 235 }
236 236
237 protected: 237 protected:
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 GpuFeatureType type = 477 GpuFeatureType type =
478 content::GpuDataManager::GetInstance()->GetBlacklistedFeatures(); 478 content::GpuDataManager::GetInstance()->GetBlacklistedFeatures();
479 EXPECT_EQ((type & content::GPU_FEATURE_TYPE_WEBGL), 479 EXPECT_EQ((type & content::GPU_FEATURE_TYPE_WEBGL),
480 content::GPU_FEATURE_TYPE_WEBGL); 480 content::GPU_FEATURE_TYPE_WEBGL);
481 481
482 bool webgl_allowed = false; 482 bool webgl_allowed = false;
483 RunTest(webgl_allowed); 483 RunTest(webgl_allowed);
484 } 484 }
485 485
486 } // namespace extensions 486 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698