OLD | NEW |
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 "chrome/browser/local_discovery/privetv3_setup_flow.h" | 5 #include "chrome/browser/local_discovery/privetv3_setup_flow.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "chrome/browser/local_discovery/gcd_api_flow.h" | 9 #include "chrome/browser/local_discovery/gcd_api_flow.h" |
10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 base::RunLoop run_loop_; | 159 base::RunLoop run_loop_; |
160 base::Closure quit_closure_; | 160 base::Closure quit_closure_; |
161 }; | 161 }; |
162 | 162 |
163 TEST_F(PrivetV3SetupFlowTest, InvalidTicket) { | 163 TEST_F(PrivetV3SetupFlowTest, InvalidTicket) { |
164 EXPECT_CALL(delegate_, OnSetupError()).Times(1); | 164 EXPECT_CALL(delegate_, OnSetupError()).Times(1); |
165 delegate_.gcd_server_response_ = "{}"; | 165 delegate_.gcd_server_response_ = "{}"; |
166 setup_.Register(kServiceName); | 166 setup_.Register(kServiceName); |
167 } | 167 } |
168 | 168 |
169 TEST_F(PrivetV3SetupFlowTest, InvalidDeviceResponce) { | 169 TEST_F(PrivetV3SetupFlowTest, InvalidDeviceResponse) { |
170 EXPECT_CALL(delegate_, OnSetupError()).Times(1); | 170 EXPECT_CALL(delegate_, OnSetupError()).Times(1); |
171 EXPECT_CALL(delegate_, ConfirmSecurityCode(_)) | 171 EXPECT_CALL(delegate_, ConfirmSecurityCode(_)) |
172 .Times(1) | 172 .Times(1) |
173 .WillOnce(WithArgs<0>(Invoke(this, &PrivetV3SetupFlowTest::ConfirmCode))); | 173 .WillOnce(WithArgs<0>(Invoke(this, &PrivetV3SetupFlowTest::ConfirmCode))); |
174 delegate_.gcd_server_response_ = kRegistrationTicketResponse; | 174 delegate_.gcd_server_response_ = kRegistrationTicketResponse; |
175 setup_.Register(kServiceName); | 175 setup_.Register(kServiceName); |
176 run_loop_.Run(); | 176 run_loop_.Run(); |
177 SimulateFetch(0, "{}"); | 177 SimulateFetch(0, "{}"); |
178 } | 178 } |
179 | 179 |
180 TEST_F(PrivetV3SetupFlowTest, Success) { | 180 TEST_F(PrivetV3SetupFlowTest, Success) { |
181 EXPECT_CALL(delegate_, OnSetupDone()).Times(1); | 181 EXPECT_CALL(delegate_, OnSetupDone()).Times(1); |
182 EXPECT_CALL(delegate_, ConfirmSecurityCode(_)) | 182 EXPECT_CALL(delegate_, ConfirmSecurityCode(_)) |
183 .Times(1) | 183 .Times(1) |
184 .WillOnce(WithArgs<0>(Invoke(this, &PrivetV3SetupFlowTest::ConfirmCode))); | 184 .WillOnce(WithArgs<0>(Invoke(this, &PrivetV3SetupFlowTest::ConfirmCode))); |
185 delegate_.gcd_server_response_ = kRegistrationTicketResponse; | 185 delegate_.gcd_server_response_ = kRegistrationTicketResponse; |
186 setup_.Register(kServiceName); | 186 setup_.Register(kServiceName); |
187 run_loop_.Run(); | 187 run_loop_.Run(); |
188 SimulateFetch(200, "{}"); | 188 SimulateFetch(200, "{}"); |
189 } | 189 } |
190 | 190 |
191 } // namespace | 191 } // namespace |
192 | 192 |
193 } // namespace local_discovery | 193 } // namespace local_discovery |
OLD | NEW |