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

Side by Side Diff: chrome/browser/signin/signin_browsertest.cc

Issue 48713008: [sync] Allow FakeURLFetcher to return arbitrary HTTP response codes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_
6 #define CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ 6 #define CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/browser/signin/signin_manager.h" 9 #include "chrome/browser/signin/signin_manager.h"
10 #include "chrome/browser/signin/signin_manager_factory.h" 10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "chrome/browser/signin/signin_promo.h" 11 #include "chrome/browser/signin/signin_promo.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/singleton_tabs.h" 13 #include "chrome/browser/ui/singleton_tabs.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 14 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 15 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
16 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 16 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
17 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
18 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
19 #include "chrome/test/base/ui_test_utils.h" 19 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.h"
22 #include "content/public/browser/render_process_host.h" 22 #include "content/public/browser/render_process_host.h"
23 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
24 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
25 #include "content/public/browser/web_contents_observer.h" 25 #include "content/public/browser/web_contents_observer.h"
26 #include "content/public/common/content_switches.h" 26 #include "content/public/common/content_switches.h"
27 #include "google_apis/gaia/gaia_urls.h" 27 #include "google_apis/gaia/gaia_urls.h"
28 #include "net/http/http_status_code.h"
28 #include "net/url_request/test_url_fetcher_factory.h" 29 #include "net/url_request/test_url_fetcher_factory.h"
29 30
30 namespace { 31 namespace {
31 const char kNonSigninURL[] = "www.google.com"; 32 const char kNonSigninURL[] = "www.google.com";
32 } 33 }
33 34
34 class SigninBrowserTest : public InProcessBrowserTest { 35 class SigninBrowserTest : public InProcessBrowserTest {
35 public: 36 public:
36 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
37 https_server_.reset(new net::SpawnedTestServer( 38 https_server_.reset(new net::SpawnedTestServer(
(...skipping 11 matching lines...) Expand all
49 ",EXCLUDE localhost"); 50 ",EXCLUDE localhost");
50 command_line->AppendSwitch(switches::kIgnoreCertificateErrors); 51 command_line->AppendSwitch(switches::kIgnoreCertificateErrors);
51 } 52 }
52 53
53 virtual void SetUp() OVERRIDE { 54 virtual void SetUp() OVERRIDE {
54 factory_.reset(new net::URLFetcherImplFactory()); 55 factory_.reset(new net::URLFetcherImplFactory());
55 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get())); 56 fake_factory_.reset(new net::FakeURLFetcherFactory(factory_.get()));
56 fake_factory_->SetFakeResponse( 57 fake_factory_->SetFakeResponse(
57 GaiaUrls::GetInstance()->service_login_url(), 58 GaiaUrls::GetInstance()->service_login_url(),
58 std::string(), 59 std::string(),
59 true); 60 net::HTTP_OK);
60 fake_factory_->SetFakeResponse(GURL(kNonSigninURL), std::string(), true); 61 fake_factory_->SetFakeResponse(GURL(kNonSigninURL),
62 std::string(),
63 net::HTTP_OK);
61 // Yield control back to the InProcessBrowserTest framework. 64 // Yield control back to the InProcessBrowserTest framework.
62 InProcessBrowserTest::SetUp(); 65 InProcessBrowserTest::SetUp();
63 } 66 }
64 67
65 virtual void TearDown() OVERRIDE { 68 virtual void TearDown() OVERRIDE {
66 if (fake_factory_.get()) { 69 if (fake_factory_.get()) {
67 fake_factory_->ClearFakeResponses(); 70 fake_factory_->ClearFakeResponses();
68 fake_factory_.reset(); 71 fake_factory_.reset();
69 } 72 }
70 73
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 EXPECT_EQ(skip_url, web_contents->GetLastCommittedURL()); 233 EXPECT_EQ(skip_url, web_contents->GetLastCommittedURL());
231 EXPECT_EQ(ntp_url, web_contents->GetVisibleURL()); 234 EXPECT_EQ(ntp_url, web_contents->GetVisibleURL());
232 235
233 content::WindowedNotificationObserver observer( 236 content::WindowedNotificationObserver observer(
234 content::NOTIFICATION_LOAD_STOP, 237 content::NOTIFICATION_LOAD_STOP,
235 content::NotificationService::AllSources()); 238 content::NotificationService::AllSources());
236 observer.Wait(); 239 observer.Wait();
237 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL()); 240 EXPECT_EQ(start_url, web_contents->GetLastCommittedURL());
238 } 241 }
239 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_ 242 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_BROWSERTEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698