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

Side by Side Diff: headless/lib/embedder_mojo_browsertest.cc

Issue 2642683004: [headless] Ensure devtooled tests call Disable/RemoveObserver. (Closed)
Patch Set: . Created 3 years, 11 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
« no previous file with comments | « no previous file | headless/lib/headless_devtools_client_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <memory> 5 #include <memory>
6 #include "base/optional.h" 6 #include "base/optional.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 void RunMojoTest() override { 227 void RunMojoTest() override {
228 devtools_client_->GetNetwork()->AddObserver(this); 228 devtools_client_->GetNetwork()->AddObserver(this);
229 devtools_client_->GetNetwork()->Enable(); 229 devtools_client_->GetNetwork()->Enable();
230 } 230 }
231 231
232 GURL GetInitialUrl() const override { 232 GURL GetInitialUrl() const override {
233 return embedded_test_server()->GetURL("/page_one.html"); 233 return embedded_test_server()->GetURL("/page_one.html");
234 } 234 }
235 235
236 void ReturnTestResult(const std::string& result) override { 236 void ReturnTestResult(const std::string& result) override {
237 FinishAsynchronousTest(); 237 DisableClientAndFinishAsynchronousTest();
238 FAIL() << "The HTTP page should not have been served and we should not have" 238 FAIL() << "The HTTP page should not have been served and we should not have"
239 " recieved a mojo callback!"; 239 " recieved a mojo callback!";
240 } 240 }
241 241
242 void OnLoadingFailed(const network::LoadingFailedParams& params) override { 242 void OnLoadingFailed(const network::LoadingFailedParams& params) override {
243 // The navigation should fail since HTTP requests are blackholed. 243 // The navigation should fail since HTTP requests are blackholed.
244 EXPECT_EQ(params.GetErrorText(), "net::ERR_FILE_NOT_FOUND"); 244 EXPECT_EQ(params.GetErrorText(), "net::ERR_FILE_NOT_FOUND");
245 DisableClientAndFinishAsynchronousTest();
246 }
247
248 void DisableClientAndFinishAsynchronousTest() {
249 devtools_client_->GetNetwork()->Disable();
250 devtools_client_->GetNetwork()->RemoveObserver(this);
245 FinishAsynchronousTest(); 251 FinishAsynchronousTest();
246 } 252 }
247 }; 253 };
248 254
249 DEVTOOLS_CLIENT_TEST_F(HttpDisabledByDefaultWhenMojoBindingsUsed); 255 DEVTOOLS_CLIENT_TEST_F(HttpDisabledByDefaultWhenMojoBindingsUsed);
250 256
251 } // namespace headless 257 } // namespace headless
OLDNEW
« no previous file with comments | « no previous file | headless/lib/headless_devtools_client_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698