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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 using ::testing::Return; | 30 using ::testing::Return; |
31 using ::testing::_; | 31 using ::testing::_; |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter { | 35 class TestContextURLRequestContextGetter : public net::URLRequestContextGetter { |
36 public: | 36 public: |
37 TestContextURLRequestContextGetter() | 37 TestContextURLRequestContextGetter() |
38 : null_task_runner_(new base::NullTaskRunner) {} | 38 : null_task_runner_(new base::NullTaskRunner) {} |
39 | 39 |
40 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE { | 40 virtual net::URLRequestContext* GetURLRequestContext() override { |
41 return &context_; | 41 return &context_; |
42 } | 42 } |
43 | 43 |
44 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() | 44 virtual scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner() |
45 const OVERRIDE { | 45 const override { |
46 return null_task_runner_; | 46 return null_task_runner_; |
47 } | 47 } |
48 | 48 |
49 private: | 49 private: |
50 virtual ~TestContextURLRequestContextGetter() {} | 50 virtual ~TestContextURLRequestContextGetter() {} |
51 | 51 |
52 net::TestURLRequestContext context_; | 52 net::TestURLRequestContext context_; |
53 scoped_refptr<base::SingleThreadTaskRunner> null_task_runner_; | 53 scoped_refptr<base::SingleThreadTaskRunner> null_task_runner_; |
54 }; | 54 }; |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 namespace chromeos { | 58 namespace chromeos { |
59 | 59 |
60 class OnlineAttemptTest : public testing::Test { | 60 class OnlineAttemptTest : public testing::Test { |
61 public: | 61 public: |
62 OnlineAttemptTest() | 62 OnlineAttemptTest() |
63 : state_(UserContext(), false), | 63 : state_(UserContext(), false), |
64 attempt_(new OnlineAttempt(&state_, &resolver_)) {} | 64 attempt_(new OnlineAttempt(&state_, &resolver_)) {} |
65 | 65 |
66 virtual void SetUp() OVERRIDE { | 66 virtual void SetUp() override { |
67 message_loop_ = base::MessageLoopProxy::current(); | 67 message_loop_ = base::MessageLoopProxy::current(); |
68 request_context_ = new TestContextURLRequestContextGetter(); | 68 request_context_ = new TestContextURLRequestContextGetter(); |
69 } | 69 } |
70 | 70 |
71 void RunFailureTest(const GoogleServiceAuthError& error) { | 71 void RunFailureTest(const GoogleServiceAuthError& error) { |
72 EXPECT_CALL(resolver_, Resolve()).Times(1).RetiresOnSaturation(); | 72 EXPECT_CALL(resolver_, Resolve()).Times(1).RetiresOnSaturation(); |
73 | 73 |
74 message_loop_->PostTask(FROM_HERE, | 74 message_loop_->PostTask(FROM_HERE, |
75 base::Bind(&OnlineAttempt::OnClientLoginFailure, | 75 base::Bind(&OnlineAttempt::OnClientLoginFailure, |
76 attempt_->weak_factory_.GetWeakPtr(), | 76 attempt_->weak_factory_.GetWeakPtr(), |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 attempt_->weak_factory_.GetWeakPtr(), | 237 attempt_->weak_factory_.GetWeakPtr(), |
238 error)); | 238 error)); |
239 | 239 |
240 // Force UI thread to finish tasks so I can verify |state_|. | 240 // Force UI thread to finish tasks so I can verify |state_|. |
241 base::RunLoop().RunUntilIdle(); | 241 base::RunLoop().RunUntilIdle(); |
242 EXPECT_TRUE(GoogleServiceAuthError::AuthErrorNone() == | 242 EXPECT_TRUE(GoogleServiceAuthError::AuthErrorNone() == |
243 state_.online_outcome().error()); | 243 state_.online_outcome().error()); |
244 } | 244 } |
245 | 245 |
246 } // namespace chromeos | 246 } // namespace chromeos |
OLD | NEW |