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

Side by Side Diff: chrome/browser/extensions/api/streams_private/streams_private_apitest.cc

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/download/download_prefs.h" 8 #include "chrome/browser/download/download_prefs.h"
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 25 matching lines...) Expand all
36 using content::DownloadManager; 36 using content::DownloadManager;
37 using content::DownloadUrlParameters; 37 using content::DownloadUrlParameters;
38 using content::ResourceController; 38 using content::ResourceController;
39 using content::WebContents; 39 using content::WebContents;
40 using extensions::Event; 40 using extensions::Event;
41 using extensions::ExtensionSystem; 41 using extensions::ExtensionSystem;
42 using extensions::ResultCatcher; 42 using extensions::ResultCatcher;
43 using net::test_server::BasicHttpResponse; 43 using net::test_server::BasicHttpResponse;
44 using net::test_server::HttpRequest; 44 using net::test_server::HttpRequest;
45 using net::test_server::HttpResponse; 45 using net::test_server::HttpResponse;
46 using net::test_server::EmbeddedTestServer;
47 using testing::_; 46 using testing::_;
48 47
49 namespace streams_private = extensions::api::streams_private; 48 namespace streams_private = extensions::api::streams_private;
50 49
51 namespace { 50 namespace {
52 51
53 // Test server's request handler. 52 // Test server's request handler.
54 // Returns response that should be sent by the test server. 53 // Returns response that should be sent by the test server.
55 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { 54 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) {
56 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse()); 55 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse());
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // extension to have MIME type 'application/msword' and the resources that 128 // extension to have MIME type 'application/msword' and the resources that
130 // should be downloaded by the browser to have MIME type 'text/plain'. 129 // should be downloaded by the browser to have MIME type 'text/plain'.
131 class StreamsPrivateApiTest : public ExtensionApiTest { 130 class StreamsPrivateApiTest : public ExtensionApiTest {
132 public: 131 public:
133 StreamsPrivateApiTest() {} 132 StreamsPrivateApiTest() {}
134 133
135 ~StreamsPrivateApiTest() override {} 134 ~StreamsPrivateApiTest() override {}
136 135
137 void SetUpOnMainThread() override { 136 void SetUpOnMainThread() override {
138 // Init test server. 137 // Init test server.
139 test_server_.reset(new EmbeddedTestServer); 138 test_server_.reset(new net::EmbeddedTestServer);
140 ASSERT_TRUE(test_server_->InitializeAndWaitUntilReady()); 139 ASSERT_TRUE(test_server_->Start());
141 test_server_->RegisterRequestHandler(base::Bind(&HandleRequest)); 140 test_server_->RegisterRequestHandler(base::Bind(&HandleRequest));
142 141
143 ExtensionApiTest::SetUpOnMainThread(); 142 ExtensionApiTest::SetUpOnMainThread();
144 } 143 }
145 144
146 void TearDownOnMainThread() override { 145 void TearDownOnMainThread() override {
147 // Tear down the test server. 146 // Tear down the test server.
148 EXPECT_TRUE(test_server_->ShutdownAndWaitUntilComplete()); 147 EXPECT_TRUE(test_server_->ShutdownAndWaitUntilComplete());
149 test_server_.reset(); 148 test_server_.reset();
150 ExtensionApiTest::TearDownOnMainThread(); 149 ExtensionApiTest::TearDownOnMainThread();
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 DownloadManager* manager) { 227 DownloadManager* manager) {
229 scoped_refptr<content::DownloadTestFlushObserver> flush_observer( 228 scoped_refptr<content::DownloadTestFlushObserver> flush_observer(
230 new content::DownloadTestFlushObserver(manager)); 229 new content::DownloadTestFlushObserver(manager));
231 download->Remove(); 230 download->Remove();
232 flush_observer->WaitForFlush(); 231 flush_observer->WaitForFlush();
233 } 232 }
234 233
235 protected: 234 protected:
236 std::string test_extension_id_; 235 std::string test_extension_id_;
237 // The HTTP server used in the tests. 236 // The HTTP server used in the tests.
238 scoped_ptr<EmbeddedTestServer> test_server_; 237 scoped_ptr<net::EmbeddedTestServer> test_server_;
239 base::ScopedTempDir downloads_dir_; 238 base::ScopedTempDir downloads_dir_;
240 }; 239 };
241 240
242 // Tests that navigating to a resource with a MIME type handleable by an 241 // Tests that navigating to a resource with a MIME type handleable by an
243 // installed, white-listed extension invokes the extension's 242 // installed, white-listed extension invokes the extension's
244 // onExecuteContentHandler event (and does not start a download). 243 // onExecuteContentHandler event (and does not start a download).
245 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Navigate) { 244 IN_PROC_BROWSER_TEST_F(StreamsPrivateApiTest, Navigate) {
246 #if defined(OS_WIN) && defined(USE_ASH) 245 #if defined(OS_WIN) && defined(USE_ASH)
247 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 246 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
248 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 247 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 base::MessageLoop::current()->RunUntilIdle(); 480 base::MessageLoop::current()->RunUntilIdle();
482 EXPECT_TRUE(catcher.GetNextResult()); 481 EXPECT_TRUE(catcher.GetNextResult());
483 482
484 ui_test_utils::NavigateToURL(browser(), 483 ui_test_utils::NavigateToURL(browser(),
485 test_server_->GetURL("/abort.rtf")); 484 test_server_->GetURL("/abort.rtf"));
486 base::MessageLoop::current()->RunUntilIdle(); 485 base::MessageLoop::current()->RunUntilIdle();
487 EXPECT_TRUE(catcher.GetNextResult()); 486 EXPECT_TRUE(catcher.GetNextResult());
488 } 487 }
489 488
490 } // namespace 489 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_apitest.cc ('k') | chrome/browser/extensions/api/tabs/tabs_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698