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

Side by Side Diff: chrome/browser/chromeos/login/signin/oauth2_browsertest.cc

Issue 1870793002: Convert //chrome/browser/chromeos from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iwyu fixes Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string> 5 #include <string>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 516
517 // FakeGoogle serves content of http://www.google.com/hello_google page for 517 // FakeGoogle serves content of http://www.google.com/hello_google page for
518 // merge session tests. 518 // merge session tests.
519 class FakeGoogle { 519 class FakeGoogle {
520 public: 520 public:
521 FakeGoogle() : start_event_(true, false) { 521 FakeGoogle() : start_event_(true, false) {
522 } 522 }
523 523
524 ~FakeGoogle() {} 524 ~FakeGoogle() {}
525 525
526 scoped_ptr<HttpResponse> HandleRequest(const HttpRequest& request) { 526 std::unique_ptr<HttpResponse> HandleRequest(const HttpRequest& request) {
527 // The scheme and host of the URL is actually not important but required to 527 // The scheme and host of the URL is actually not important but required to
528 // get a valid GURL in order to parse |request.relative_url|. 528 // get a valid GURL in order to parse |request.relative_url|.
529 GURL request_url = GURL("http://localhost").Resolve(request.relative_url); 529 GURL request_url = GURL("http://localhost").Resolve(request.relative_url);
530 LOG(WARNING) << "Requesting page " << request.relative_url; 530 LOG(WARNING) << "Requesting page " << request.relative_url;
531 std::string request_path = request_url.path(); 531 std::string request_path = request_url.path();
532 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); 532 std::unique_ptr<BasicHttpResponse> http_response(new BasicHttpResponse());
533 if (request_path == kHelloPagePath) { // Serving "google" page. 533 if (request_path == kHelloPagePath) { // Serving "google" page.
534 start_event_.Signal(); 534 start_event_.Signal();
535 content::BrowserThread::PostTask( 535 content::BrowserThread::PostTask(
536 content::BrowserThread::UI, FROM_HERE, 536 content::BrowserThread::UI, FROM_HERE,
537 base::Bind(&FakeGoogle::QuitRunnerOnUIThread, 537 base::Bind(&FakeGoogle::QuitRunnerOnUIThread,
538 base::Unretained(this))); 538 base::Unretained(this)));
539 539
540 http_response->set_code(net::HTTP_OK); 540 http_response->set_code(net::HTTP_OK);
541 http_response->set_content_type("text/html"); 541 http_response->set_content_type("text/html");
542 http_response->set_content(kGooglePageContent); 542 http_response->set_content(kGooglePageContent);
543 } else if (request_path == kRandomPagePath) { // Serving "non-google" page. 543 } else if (request_path == kRandomPagePath) { // Serving "non-google" page.
544 http_response->set_code(net::HTTP_OK); 544 http_response->set_code(net::HTTP_OK);
545 http_response->set_content_type("text/html"); 545 http_response->set_content_type("text/html");
546 http_response->set_content(kRandomPageContent); 546 http_response->set_content(kRandomPageContent);
547 } else { 547 } else {
548 return scoped_ptr<HttpResponse>(); // Request not understood. 548 return std::unique_ptr<HttpResponse>(); // Request not understood.
549 } 549 }
550 550
551 return std::move(http_response); 551 return std::move(http_response);
552 } 552 }
553 553
554 // True if we have already served the test page. 554 // True if we have already served the test page.
555 bool IsPageRequested() { return start_event_.IsSignaled(); } 555 bool IsPageRequested() { return start_event_.IsSignaled(); }
556 556
557 // Waits until we receive a request to serve the test page. 557 // Waits until we receive a request to serve the test page.
558 void WaitForPageRequest() { 558 void WaitForPageRequest() {
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 WaitForMergeSessionToStart(); 763 WaitForMergeSessionToStart();
764 764
765 // Reset ExtensionBrowserTest::observer_ to the right browser object. 765 // Reset ExtensionBrowserTest::observer_ to the right browser object.
766 Browser* browser = FindOrCreateVisibleBrowser(profile()); 766 Browser* browser = FindOrCreateVisibleBrowser(profile());
767 observer_.reset(new ExtensionTestNotificationObserver(browser)); 767 observer_.reset(new ExtensionTestNotificationObserver(browser));
768 768
769 // Run background page tests. The tests will just wait for XHR request 769 // Run background page tests. The tests will just wait for XHR request
770 // to complete. 770 // to complete.
771 extensions::ResultCatcher catcher; 771 extensions::ResultCatcher catcher;
772 772
773 scoped_ptr<ExtensionTestMessageListener> non_google_xhr_listener( 773 std::unique_ptr<ExtensionTestMessageListener> non_google_xhr_listener(
774 new ExtensionTestMessageListener("non-google-xhr-received", false)); 774 new ExtensionTestMessageListener("non-google-xhr-received", false));
775 775
776 // Load extension with a background page. The background page will 776 // Load extension with a background page. The background page will
777 // attempt to load |fake_google_page_url_| via XHR. 777 // attempt to load |fake_google_page_url_| via XHR.
778 const extensions::Extension* ext = LoadExtension( 778 const extensions::Extension* ext = LoadExtension(
779 test_data_dir_.AppendASCII("merge_session")); 779 test_data_dir_.AppendASCII("merge_session"));
780 ASSERT_TRUE(ext); 780 ASSERT_TRUE(ext);
781 781
782 // Kick off XHR request from the extension. 782 // Kick off XHR request from the extension.
783 JsExpectOnBackgroundPage( 783 JsExpectOnBackgroundPage(
(...skipping 20 matching lines...) Expand all
804 804
805 if (!catcher.GetNextResult()) { 805 if (!catcher.GetNextResult()) {
806 std::string message = catcher.message(); 806 std::string message = catcher.message();
807 ADD_FAILURE() << "Tests failed: " << message; 807 ADD_FAILURE() << "Tests failed: " << message;
808 } 808 }
809 809
810 EXPECT_TRUE(fake_google_.IsPageRequested()); 810 EXPECT_TRUE(fake_google_.IsPageRequested());
811 } 811 }
812 812
813 } // namespace chromeos 813 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698