OLD | NEW |
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/url_request/test_url_fetcher_factory.h" | 16 #include "net/url_request/test_url_fetcher_factory.h" |
16 #include "net/url_request/url_fetcher_impl.h" | 17 #include "net/url_request/url_fetcher_impl.h" |
17 #include "net/url_request/url_request_test_util.h" | 18 #include "net/url_request/url_request_test_util.h" |
18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "url/gurl.h" | 21 #include "url/gurl.h" |
21 | 22 |
22 using testing::Mock; | 23 using testing::Mock; |
23 using testing::NiceMock; | 24 using testing::NiceMock; |
24 using testing::StrictMock; | 25 using testing::StrictMock; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 scoped_ptr<net::FakeURLFetcherFactory> fetcher_factory_; | 100 scoped_ptr<net::FakeURLFetcherFactory> fetcher_factory_; |
100 TestOAuth2TokenService token_service_; | 101 TestOAuth2TokenService token_service_; |
101 StrictMock<MockDelegate> delegate_; | 102 StrictMock<MockDelegate> delegate_; |
102 scoped_ptr<CloudPrintPrinterList> printer_list_; | 103 scoped_ptr<CloudPrintPrinterList> printer_list_; |
103 }; | 104 }; |
104 | 105 |
105 TEST_F(CloudPrintPrinterListTest, SuccessOAuth2) { | 106 TEST_F(CloudPrintPrinterListTest, SuccessOAuth2) { |
106 fetcher_factory_->SetFakeResponse( | 107 fetcher_factory_->SetFakeResponse( |
107 GURL("http://SoMeUrL.com/cloudprint/search"), | 108 GURL("http://SoMeUrL.com/cloudprint/search"), |
108 kSampleSuccessResponseOAuth, | 109 kSampleSuccessResponseOAuth, |
109 true); | 110 net::HTTP_OK); |
110 | 111 |
111 CloudPrintBaseApiFlow* cloudprint_flow = | 112 CloudPrintBaseApiFlow* cloudprint_flow = |
112 printer_list_->GetOAuth2ApiFlowForTests(); | 113 printer_list_->GetOAuth2ApiFlowForTests(); |
113 | 114 |
114 printer_list_->Start(); | 115 printer_list_->Start(); |
115 | 116 |
116 cloudprint_flow->OnGetTokenSuccess(NULL, "SomeToken", base::Time()); | 117 cloudprint_flow->OnGetTokenSuccess(NULL, "SomeToken", base::Time()); |
117 | 118 |
118 EXPECT_CALL(delegate_, OnCloudPrintPrinterListReady()); | 119 EXPECT_CALL(delegate_, OnCloudPrintPrinterListReady()); |
119 | 120 |
(...skipping 19 matching lines...) Expand all Loading... |
139 printer_list_->GetDetailsFor("someID"); | 140 printer_list_->GetDetailsFor("someID"); |
140 ASSERT_TRUE(found != NULL); | 141 ASSERT_TRUE(found != NULL); |
141 EXPECT_EQ("someID", found->id); | 142 EXPECT_EQ("someID", found->id); |
142 EXPECT_EQ("someDisplayName", found->display_name); | 143 EXPECT_EQ("someDisplayName", found->display_name); |
143 EXPECT_EQ("someDescription", found->description); | 144 EXPECT_EQ("someDescription", found->description); |
144 } | 145 } |
145 | 146 |
146 } // namespace | 147 } // namespace |
147 | 148 |
148 } // namespace local_discovery | 149 } // namespace local_discovery |
OLD | NEW |