Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_PROXIMITY_AUTH_FAKE_CRYPTAUTH_FAKE_CRYPTAUTH_GCM_MANAGER_H | |
| 6 #define COMPONENTS_PROXIMITY_AUTH_FAKE_CRYPTAUTH_FAKE_CRYPTAUTH_GCM_MANAGER_H | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/observer_list.h" | |
| 10 #include "components/proximity_auth/cryptauth/cryptauth_gcm_manager.h" | |
| 11 | |
| 12 namespace proximity_auth { | |
| 13 | |
| 14 // CryptAuthGCMManager implementation for testing purposes. | |
| 15 class FakeCryptAuthGCMManager : public CryptAuthGCMManager { | |
| 16 public: | |
| 17 // Creates the instance: | |
| 18 // |registration_id|: The GCM registration id from a previous successful | |
| 19 // enrollment. Pass in an empty |registration_id| to simulate never having | |
| 20 // registered successfully. | |
| 21 FakeCryptAuthGCMManager(const std::string& registration_id); | |
|
sacomoto
2015/07/27 16:56:51
Use |explicit| for single argument constructors.
Tim Song
2015/07/28 16:45:19
Done.
| |
| 22 | |
| 23 ~FakeCryptAuthGCMManager() override; | |
| 24 | |
| 25 // CryptAuthGCMManager: | |
| 26 void StartListening() override; | |
| 27 void RegisterWithGCM() override; | |
| 28 std::string GetRegistrationId() override; | |
| 29 void AddObserver(Observer* observer) override; | |
| 30 void RemoveObserver(Observer* observer) override; | |
| 31 | |
| 32 // Simulates completing a GCM registration with the resulting | |
| 33 // |registration_id|. Passing in an empty |registration_id| will simulate a | |
|
sacomoto
2015/07/27 16:56:51
nit: s/in an/an/.
Tim Song
2015/07/28 16:45:19
Done.
| |
| 34 // registration failure. | |
| 35 // A registration attempt must currently be in progress. | |
| 36 void CompleteRegistration(const std::string& registration_id); | |
| 37 | |
| 38 // Simulates receiving a re-enroll push message from GCM. | |
| 39 void PushReenrollMessage(); | |
| 40 | |
| 41 // Simulates receiving a re-sync push message from GCM. | |
| 42 void PushResyncMessage(); | |
| 43 | |
| 44 bool registration_in_progress() { return registration_in_progress_; } | |
| 45 | |
| 46 void set_registration_id(const std::string& registration_id) { | |
| 47 registration_id_ = registration_id; | |
| 48 } | |
| 49 | |
| 50 private: | |
| 51 // Whether a registration attempt is currently in progress. | |
| 52 bool registration_in_progress_; | |
| 53 | |
| 54 // The registration id obtained from the last successful registration. | |
| 55 std::string registration_id_; | |
| 56 | |
| 57 base::ObserverList<Observer> observers_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(FakeCryptAuthGCMManager); | |
| 60 }; | |
| 61 | |
| 62 } // namespace proximity_auth | |
| 63 | |
| 64 #endif // COMPONENTS_PROXIMITY_FAKE_CRYPTAUTH_FAKE_CRYPTAUTH_GCM_MANAGER_H | |
| OLD | NEW |