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

Side by Side Diff: chrome/browser/chromeos/attestation/attestation_ca_client_unittest.cc

Issue 2799883003: Switch from TestBrowserThread to TestBrowserThreadBundle in chrome. (Closed)
Patch Set: fix-string Created 3 years, 7 months 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
OLDNEW
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 "chrome/browser/chromeos/attestation/attestation_ca_client.h"
6
5 #include "base/bind.h" 7 #include "base/bind.h"
6 #include "base/command_line.h" 8 #include "base/command_line.h"
7 #include "base/message_loop/message_loop.h"
8 #include "chrome/browser/chromeos/attestation/attestation_ca_client.h"
9 #include "chromeos/chromeos_switches.h" 9 #include "chromeos/chromeos_switches.h"
10 #include "content/public/test/test_browser_thread.h" 10 #include "content/public/test/test_browser_thread_bundle.h"
11 #include "net/base/net_errors.h" 11 #include "net/base/net_errors.h"
12 #include "net/http/http_status_code.h" 12 #include "net/http/http_status_code.h"
13 #include "net/url_request/test_url_fetcher_factory.h" 13 #include "net/url_request/test_url_fetcher_factory.h"
14 #include "net/url_request/url_fetcher.h" 14 #include "net/url_request/url_fetcher.h"
15 #include "net/url_request/url_request_status.h" 15 #include "net/url_request/url_request_status.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 namespace attestation { 19 namespace attestation {
20 20
21 class AttestationCAClientTest : public ::testing::Test { 21 class AttestationCAClientTest : public ::testing::Test {
22 public: 22 public:
23 AttestationCAClientTest() 23 AttestationCAClientTest() : num_invocations_(0), result_(false) {}
24 : io_thread_(content::BrowserThread::IO, &message_loop_),
25 num_invocations_(0),
26 result_(false) {
27 }
28 24
29 ~AttestationCAClientTest() override {} 25 ~AttestationCAClientTest() override {}
30 26
31 void DataCallback(bool result, const std::string& data) { 27 void DataCallback(bool result, const std::string& data) {
32 ++num_invocations_; 28 ++num_invocations_;
33 result_ = result; 29 result_ = result;
34 data_ = data; 30 data_ = data;
35 } 31 }
36 32
37 void DeleteClientDataCallback(AttestationCAClient* client, 33 void DeleteClientDataCallback(AttestationCAClient* client,
(...skipping 21 matching lines...) Expand all
59 55
60 void SendFetcherResponse(net::TestURLFetcher* fetcher, 56 void SendFetcherResponse(net::TestURLFetcher* fetcher,
61 net::Error error, 57 net::Error error,
62 int response_code) { 58 int response_code) {
63 fetcher->set_status(net::URLRequestStatus::FromError(error)); 59 fetcher->set_status(net::URLRequestStatus::FromError(error));
64 fetcher->set_response_code(response_code); 60 fetcher->set_response_code(response_code);
65 fetcher->SetResponseString(fetcher->upload_data() + "_response"); 61 fetcher->SetResponseString(fetcher->upload_data() + "_response");
66 fetcher->delegate()->OnURLFetchComplete(fetcher); 62 fetcher->delegate()->OnURLFetchComplete(fetcher);
67 } 63 }
68 64
69 base::MessageLoop message_loop_; 65 content::TestBrowserThreadBundle test_browser_thread_bundle_;
70 content::TestBrowserThread io_thread_;
71 net::TestURLFetcherFactory url_fetcher_factory_; 66 net::TestURLFetcherFactory url_fetcher_factory_;
72 67
73 // For use with DataCallback. 68 // For use with DataCallback.
74 int num_invocations_; 69 int num_invocations_;
75 bool result_; 70 bool result_;
76 std::string data_; 71 std::string data_;
77 }; 72 };
78 73
79 TEST_F(AttestationCAClientTest, EnrollRequest) { 74 TEST_F(AttestationCAClientTest, EnrollRequest) {
80 AttestationCAClient client; 75 AttestationCAClient client;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 CheckURLAndSendResponse(GURL("https://asbestos-qa.corp.google.com/sign"), 197 CheckURLAndSendResponse(GURL("https://asbestos-qa.corp.google.com/sign"),
203 net::OK, net::HTTP_OK); 198 net::OK, net::HTTP_OK);
204 199
205 EXPECT_EQ(1, num_invocations_); 200 EXPECT_EQ(1, num_invocations_);
206 EXPECT_TRUE(result_); 201 EXPECT_TRUE(result_);
207 EXPECT_EQ("certificate_response", data_); 202 EXPECT_EQ("certificate_response", data_);
208 } 203 }
209 204
210 } // namespace attestation 205 } // namespace attestation
211 } // namespace chromeos 206 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698