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

Side by Side Diff: chrome/browser/local_discovery/cloud_print_printer_list_unittest.cc

Issue 60923002: [sync] Allow FakeURLFetcher to return an arbitrary URLRequestStatus (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 #include <set> 5 #include <set>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/local_discovery/cloud_print_printer_list.h" 9 #include "chrome/browser/local_discovery/cloud_print_printer_list.h"
10 #include "content/public/test/test_browser_thread.h" 10 #include "content/public/test/test_browser_thread.h"
11 #include "google_apis/gaia/google_service_auth_error.h" 11 #include "google_apis/gaia/google_service_auth_error.h"
12 #include "net/base/host_port_pair.h" 12 #include "net/base/host_port_pair.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/http/http_request_headers.h" 14 #include "net/http/http_request_headers.h"
15 #include "net/http/http_status_code.h" 15 #include "net/http/http_status_code.h"
16 #include "net/url_request/test_url_fetcher_factory.h" 16 #include "net/url_request/test_url_fetcher_factory.h"
17 #include "net/url_request/url_fetcher_impl.h" 17 #include "net/url_request/url_fetcher_impl.h"
18 #include "net/url_request/url_request_status.h"
18 #include "net/url_request/url_request_test_util.h" 19 #include "net/url_request/url_request_test_util.h"
19 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "url/gurl.h" 22 #include "url/gurl.h"
22 23
23 using testing::Mock; 24 using testing::Mock;
24 using testing::NiceMock; 25 using testing::NiceMock;
25 using testing::StrictMock; 26 using testing::StrictMock;
26 27
27 namespace local_discovery { 28 namespace local_discovery {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 scoped_ptr<net::FakeURLFetcherFactory> fetcher_factory_; 101 scoped_ptr<net::FakeURLFetcherFactory> fetcher_factory_;
101 TestOAuth2TokenService token_service_; 102 TestOAuth2TokenService token_service_;
102 StrictMock<MockDelegate> delegate_; 103 StrictMock<MockDelegate> delegate_;
103 scoped_ptr<CloudPrintPrinterList> printer_list_; 104 scoped_ptr<CloudPrintPrinterList> printer_list_;
104 }; 105 };
105 106
106 TEST_F(CloudPrintPrinterListTest, SuccessOAuth2) { 107 TEST_F(CloudPrintPrinterListTest, SuccessOAuth2) {
107 fetcher_factory_->SetFakeResponse( 108 fetcher_factory_->SetFakeResponse(
108 GURL("http://SoMeUrL.com/cloudprint/search"), 109 GURL("http://SoMeUrL.com/cloudprint/search"),
109 kSampleSuccessResponseOAuth, 110 kSampleSuccessResponseOAuth,
110 net::HTTP_OK); 111 net::HTTP_OK,
112 net::URLRequestStatus::SUCCESS);
111 113
112 CloudPrintBaseApiFlow* cloudprint_flow = 114 CloudPrintBaseApiFlow* cloudprint_flow =
113 printer_list_->GetOAuth2ApiFlowForTests(); 115 printer_list_->GetOAuth2ApiFlowForTests();
114 116
115 printer_list_->Start(); 117 printer_list_->Start();
116 118
117 cloudprint_flow->OnGetTokenSuccess(NULL, "SomeToken", base::Time()); 119 cloudprint_flow->OnGetTokenSuccess(NULL, "SomeToken", base::Time());
118 120
119 EXPECT_CALL(delegate_, OnCloudPrintPrinterListReady()); 121 EXPECT_CALL(delegate_, OnCloudPrintPrinterListReady());
120 122
(...skipping 19 matching lines...) Expand all
140 printer_list_->GetDetailsFor("someID"); 142 printer_list_->GetDetailsFor("someID");
141 ASSERT_TRUE(found != NULL); 143 ASSERT_TRUE(found != NULL);
142 EXPECT_EQ("someID", found->id); 144 EXPECT_EQ("someID", found->id);
143 EXPECT_EQ("someDisplayName", found->display_name); 145 EXPECT_EQ("someDisplayName", found->display_name);
144 EXPECT_EQ("someDescription", found->description); 146 EXPECT_EQ("someDescription", found->description);
145 } 147 }
146 148
147 } // namespace 149 } // namespace
148 150
149 } // namespace local_discovery 151 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698