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 "chrome/browser/services/gcm/gcm_account_tracker.h" | 5 #include "chrome/browser/services/gcm/gcm_account_tracker.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 EXPECT_EQ(expected_iter->email, actual_iter->email); | 61 EXPECT_EQ(expected_iter->email, actual_iter->email); |
62 EXPECT_EQ(expected_iter->access_token, actual_iter->access_token); | 62 EXPECT_EQ(expected_iter->access_token, actual_iter->access_token); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 // This version of FakeGCMDriver is customized around handling accounts and | 66 // This version of FakeGCMDriver is customized around handling accounts and |
67 // connection events for testing GCMAccountTracker. | 67 // connection events for testing GCMAccountTracker. |
68 class CustomFakeGCMDriver : public FakeGCMDriver { | 68 class CustomFakeGCMDriver : public FakeGCMDriver { |
69 public: | 69 public: |
70 CustomFakeGCMDriver(); | 70 CustomFakeGCMDriver(); |
71 virtual ~CustomFakeGCMDriver(); | 71 ~CustomFakeGCMDriver() override; |
72 | 72 |
73 // GCMDriver overrides: | 73 // GCMDriver overrides: |
74 virtual void SetAccountTokens( | 74 void SetAccountTokens( |
75 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override; | 75 const std::vector<GCMClient::AccountTokenInfo>& account_tokens) override; |
76 virtual void AddConnectionObserver(GCMConnectionObserver* observer) override; | 76 void AddConnectionObserver(GCMConnectionObserver* observer) override; |
77 virtual void RemoveConnectionObserver( | 77 void RemoveConnectionObserver(GCMConnectionObserver* observer) override; |
78 GCMConnectionObserver* observer) override; | 78 bool IsConnected() const override { return connected_; } |
79 virtual bool IsConnected() const override { return connected_; } | |
80 | 79 |
81 // Test results and helpers. | 80 // Test results and helpers. |
82 void SetConnected(bool connected); | 81 void SetConnected(bool connected); |
83 void ResetResults(); | 82 void ResetResults(); |
84 bool update_accounts_called() const { return update_accounts_called_; } | 83 bool update_accounts_called() const { return update_accounts_called_; } |
85 const std::vector<GCMClient::AccountTokenInfo>& accounts() const { | 84 const std::vector<GCMClient::AccountTokenInfo>& accounts() const { |
86 return accounts_; | 85 return accounts_; |
87 } | 86 } |
88 const GCMConnectionObserver* last_connection_observer() const { | 87 const GCMConnectionObserver* last_connection_observer() const { |
89 return last_connection_observer_; | 88 return last_connection_observer_; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 // clean it up before the SetAccessToken is called. This also means a new | 418 // clean it up before the SetAccessToken is called. This also means a new |
420 // token request will be issued | 419 // token request will be issued |
421 EXPECT_FALSE(driver()->update_accounts_called()); | 420 EXPECT_FALSE(driver()->update_accounts_called()); |
422 EXPECT_EQ(1UL, tracker()->get_pending_token_request_count()); | 421 EXPECT_EQ(1UL, tracker()->get_pending_token_request_count()); |
423 } | 422 } |
424 | 423 |
425 // TODO(fgorski): Add test for adding account after removal >> make sure it does | 424 // TODO(fgorski): Add test for adding account after removal >> make sure it does |
426 // not mark removal. | 425 // not mark removal. |
427 | 426 |
428 } // namespace gcm | 427 } // namespace gcm |
OLD | NEW |