OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <ostream> | 5 #include <ostream> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "chrome/browser/policy/device_management_backend_impl.h" | 10 #include "chrome/browser/policy/device_management_backend_impl.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 TestURLFetcher* fetcher = factory_.GetFetcherByID(0); | 158 TestURLFetcher* fetcher = factory_.GetFetcherByID(0); |
159 ASSERT_TRUE(fetcher); | 159 ASSERT_TRUE(fetcher); |
160 | 160 |
161 fetcher->set_url(GURL(kServiceUrl)); | 161 fetcher->set_url(GURL(kServiceUrl)); |
162 fetcher->set_status(GetParam().request_status_); | 162 fetcher->set_status(GetParam().request_status_); |
163 fetcher->set_response_code(GetParam().http_status_); | 163 fetcher->set_response_code(GetParam().http_status_); |
164 fetcher->SetResponseString(GetParam().response_); | 164 fetcher->SetResponseString(GetParam().response_); |
165 fetcher->delegate()->OnURLFetchComplete(fetcher); | 165 fetcher->delegate()->OnURLFetchComplete(fetcher); |
166 } | 166 } |
167 | 167 |
| 168 TEST_P(DeviceManagementServiceFailedRequestTest, AutoEnrollmentRequest) { |
| 169 DeviceAutoEnrollmentResponseDelegateMock mock; |
| 170 EXPECT_CALL(mock, OnError(GetParam().expected_error_)); |
| 171 em::DeviceAutoEnrollmentRequest request; |
| 172 request.set_modulus(1); |
| 173 request.set_remainder(0); |
| 174 backend_->ProcessAutoEnrollmentRequest(kDeviceId, request, &mock); |
| 175 TestURLFetcher* fetcher = factory_.GetFetcherByID(0); |
| 176 ASSERT_TRUE(fetcher); |
| 177 |
| 178 fetcher->set_url(GURL(kServiceUrl)); |
| 179 fetcher->set_status(GetParam().request_status_); |
| 180 fetcher->set_response_code(GetParam().http_status_); |
| 181 fetcher->SetResponseString(GetParam().response_); |
| 182 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 183 } |
| 184 |
168 INSTANTIATE_TEST_CASE_P( | 185 INSTANTIATE_TEST_CASE_P( |
169 DeviceManagementServiceFailedRequestTestInstance, | 186 DeviceManagementServiceFailedRequestTestInstance, |
170 DeviceManagementServiceFailedRequestTest, | 187 DeviceManagementServiceFailedRequestTest, |
171 testing::Values( | 188 testing::Values( |
172 FailedRequestParams( | 189 FailedRequestParams( |
173 DeviceManagementBackend::kErrorRequestFailed, | 190 DeviceManagementBackend::kErrorRequestFailed, |
174 net::URLRequestStatus::FAILED, | 191 net::URLRequestStatus::FAILED, |
175 200, | 192 200, |
176 PROTO_STRING(kResponseEmpty)), | 193 PROTO_STRING(kResponseEmpty)), |
177 FailedRequestParams( | 194 FailedRequestParams( |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 | 595 |
579 // Verify that a new URLFetcher was started that bypasses the proxy. | 596 // Verify that a new URLFetcher was started that bypasses the proxy. |
580 fetcher = factory_.GetFetcherByID(0); | 597 fetcher = factory_.GetFetcherByID(0); |
581 ASSERT_TRUE(fetcher); | 598 ASSERT_TRUE(fetcher); |
582 EXPECT_TRUE((fetcher->GetLoadFlags() & net::LOAD_BYPASS_PROXY) != 0); | 599 EXPECT_TRUE((fetcher->GetLoadFlags() & net::LOAD_BYPASS_PROXY) != 0); |
583 EXPECT_EQ(original_url, fetcher->GetOriginalURL()); | 600 EXPECT_EQ(original_url, fetcher->GetOriginalURL()); |
584 EXPECT_EQ(upload_data, fetcher->upload_data()); | 601 EXPECT_EQ(upload_data, fetcher->upload_data()); |
585 } | 602 } |
586 | 603 |
587 } // namespace policy | 604 } // namespace policy |
OLD | NEW |