OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" | 7 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h" |
8 #include "content/public/test/test_browser_thread.h" | 8 #include "content/public/test/test_browser_thread.h" |
9 #include "net/http/http_status_code.h" | 9 #include "net/http/http_status_code.h" |
10 #include "net/url_request/test_url_fetcher_factory.h" | 10 #include "net/url_request/test_url_fetcher_factory.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 protected: | 42 protected: |
43 void SendResponse(net::URLRequestStatus::Status status, int response_code) { | 43 void SendResponse(net::URLRequestStatus::Status status, int response_code) { |
44 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); | 44 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); |
45 CHECK(fetcher); | 45 CHECK(fetcher); |
46 fetcher->set_status(net::URLRequestStatus(status, 0)); | 46 fetcher->set_status(net::URLRequestStatus(status, 0)); |
47 fetcher->set_response_code(response_code); | 47 fetcher->set_response_code(response_code); |
48 fetcher->SetResponseString(fetcher->upload_data() + "_response"); | 48 fetcher->SetResponseString(fetcher->upload_data() + "_response"); |
49 fetcher->delegate()->OnURLFetchComplete(fetcher); | 49 fetcher->delegate()->OnURLFetchComplete(fetcher); |
50 } | 50 } |
51 | 51 |
52 MessageLoop message_loop_; | 52 base::MessageLoop message_loop_; |
53 content::TestBrowserThread io_thread_; | 53 content::TestBrowserThread io_thread_; |
54 net::TestURLFetcherFactory url_fetcher_factory_; | 54 net::TestURLFetcherFactory url_fetcher_factory_; |
55 | 55 |
56 // For use with DataCallback. | 56 // For use with DataCallback. |
57 int num_invocations_; | 57 int num_invocations_; |
58 bool result_; | 58 bool result_; |
59 std::string data_; | 59 std::string data_; |
60 }; | 60 }; |
61 | 61 |
62 TEST_F(AttestationCAClientTest, EnrollRequest) { | 62 TEST_F(AttestationCAClientTest, EnrollRequest) { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 client)); | 120 client)); |
121 SendResponse(net::URLRequestStatus::SUCCESS, net::HTTP_OK); | 121 SendResponse(net::URLRequestStatus::SUCCESS, net::HTTP_OK); |
122 | 122 |
123 EXPECT_EQ(1, num_invocations_); | 123 EXPECT_EQ(1, num_invocations_); |
124 EXPECT_TRUE(result_); | 124 EXPECT_TRUE(result_); |
125 EXPECT_EQ("certificate_response", data_); | 125 EXPECT_EQ("certificate_response", data_); |
126 } | 126 } |
127 | 127 |
128 } // namespace attestation | 128 } // namespace attestation |
129 } // namespace chromeos | 129 } // namespace chromeos |
OLD | NEW |