OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/gcm_driver/instance_id/instance_id_driver.h" | 5 #include "components/gcm_driver/instance_id/instance_id_driver.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop/message_loop.h" | |
10 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
11 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
12 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" | 11 #include "components/gcm_driver/instance_id/fake_gcm_driver_for_instance_id.h" |
13 #include "components/gcm_driver/instance_id/instance_id.h" | 12 #include "components/gcm_driver/instance_id/instance_id.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
15 | 14 |
16 namespace instance_id { | 15 namespace instance_id { |
17 | 16 |
18 namespace { | 17 namespace { |
19 | 18 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 69 |
71 InstanceIDDriver* driver() const { return driver_.get(); } | 70 InstanceIDDriver* driver() const { return driver_.get(); } |
72 | 71 |
73 private: | 72 private: |
74 void GetIDCompleted(const std::string& id); | 73 void GetIDCompleted(const std::string& id); |
75 void GetCreationTimeCompleted(const base::Time& creation_time); | 74 void GetCreationTimeCompleted(const base::Time& creation_time); |
76 void DeleteIDCompleted(InstanceID::Result result); | 75 void DeleteIDCompleted(InstanceID::Result result); |
77 void GetTokenCompleted(const std::string& token, InstanceID::Result result); | 76 void GetTokenCompleted(const std::string& token, InstanceID::Result result); |
78 void DeleteTokenCompleted(InstanceID::Result result); | 77 void DeleteTokenCompleted(InstanceID::Result result); |
79 | 78 |
80 base::MessageLoopForUI message_loop_; | |
81 scoped_ptr<FakeGCMDriverForInstanceID> gcm_driver_; | 79 scoped_ptr<FakeGCMDriverForInstanceID> gcm_driver_; |
82 scoped_ptr<InstanceIDDriver> driver_; | 80 scoped_ptr<InstanceIDDriver> driver_; |
83 | 81 |
84 std::string id_; | 82 std::string id_; |
85 base::Time creation_time_; | 83 base::Time creation_time_; |
86 std::string token_; | 84 std::string token_; |
87 InstanceID::Result result_; | 85 InstanceID::Result result_; |
88 | 86 |
89 bool async_operation_completed_; | 87 bool async_operation_completed_; |
90 base::Closure async_operation_completed_callback_; | 88 base::Closure async_operation_completed_callback_; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 GetToken(instance_id, kAuthorizedEntity1, kScope2, options); | 345 GetToken(instance_id, kAuthorizedEntity1, kScope2, options); |
348 EXPECT_FALSE(new_token1.empty()); | 346 EXPECT_FALSE(new_token1.empty()); |
349 EXPECT_NE(token1, new_token1); | 347 EXPECT_NE(token1, new_token1); |
350 | 348 |
351 // The other token is not affected by the deletion. | 349 // The other token is not affected by the deletion. |
352 EXPECT_EQ(token2, | 350 EXPECT_EQ(token2, |
353 GetToken(instance_id, kAuthorizedEntity2, kScope1, options)); | 351 GetToken(instance_id, kAuthorizedEntity2, kScope1, options)); |
354 } | 352 } |
355 | 353 |
356 } // instance_id | 354 } // instance_id |
OLD | NEW |