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 // A set of unit tests for TokenValidatorFactoryImpl | 5 // A set of unit tests for TokenValidatorFactoryImpl |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } // namespace | 67 } // namespace |
68 | 68 |
69 namespace remoting { | 69 namespace remoting { |
70 | 70 |
71 class TokenValidatorFactoryImplTest : public testing::Test { | 71 class TokenValidatorFactoryImplTest : public testing::Test { |
72 public: | 72 public: |
73 TokenValidatorFactoryImplTest() : message_loop_(base::MessageLoop::TYPE_IO) {} | 73 TokenValidatorFactoryImplTest() : message_loop_(base::MessageLoop::TYPE_IO) {} |
74 | 74 |
75 void SuccessCallback(const std::string& shared_secret) { | 75 void SuccessCallback(const std::string& shared_secret) { |
76 EXPECT_FALSE(shared_secret.empty()); | 76 EXPECT_FALSE(shared_secret.empty()); |
77 message_loop_.Quit(); | 77 message_loop_.QuitWhenIdle(); |
78 } | 78 } |
79 | 79 |
80 void FailureCallback(const std::string& shared_secret) { | 80 void FailureCallback(const std::string& shared_secret) { |
81 EXPECT_TRUE(shared_secret.empty()); | 81 EXPECT_TRUE(shared_secret.empty()); |
82 message_loop_.Quit(); | 82 message_loop_.QuitWhenIdle(); |
83 } | 83 } |
84 | 84 |
85 void DeleteOnFailureCallback(const std::string& shared_secret) { | 85 void DeleteOnFailureCallback(const std::string& shared_secret) { |
86 EXPECT_TRUE(shared_secret.empty()); | 86 EXPECT_TRUE(shared_secret.empty()); |
87 token_validator_.reset(); | 87 token_validator_.reset(); |
88 message_loop_.Quit(); | 88 message_loop_.QuitWhenIdle(); |
89 } | 89 } |
90 | 90 |
91 protected: | 91 protected: |
92 void SetUp() override { | 92 void SetUp() override { |
93 key_pair_ = RsaKeyPair::FromString(kTestRsaKeyPair); | 93 key_pair_ = RsaKeyPair::FromString(kTestRsaKeyPair); |
94 scoped_ptr<net::TestURLRequestContext> context( | 94 scoped_ptr<net::TestURLRequestContext> context( |
95 new SetResponseURLRequestContext()); | 95 new SetResponseURLRequestContext()); |
96 request_context_getter_ = new net::TestURLRequestContextGetter( | 96 request_context_getter_ = new net::TestURLRequestContextGetter( |
97 message_loop_.task_runner(), context.Pass()); | 97 message_loop_.task_runner(), context.Pass()); |
98 ThirdPartyAuthConfig config; | 98 ThirdPartyAuthConfig config; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 SetResponse(net::URLRequestTestJob::test_error_headers(), std::string()); | 181 SetResponse(net::URLRequestTestJob::test_error_headers(), std::string()); |
182 | 182 |
183 token_validator_->ValidateThirdPartyToken( | 183 token_validator_->ValidateThirdPartyToken( |
184 kToken, base::Bind( | 184 kToken, base::Bind( |
185 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, | 185 &TokenValidatorFactoryImplTest::DeleteOnFailureCallback, |
186 base::Unretained(this))); | 186 base::Unretained(this))); |
187 message_loop_.Run(); | 187 message_loop_.Run(); |
188 } | 188 } |
189 | 189 |
190 } // namespace remoting | 190 } // namespace remoting |
OLD | NEW |