| 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 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ |
| 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "google_apis/gcm/gcm_client.h" | 10 #include "google_apis/gcm/gcm_client.h" |
| 11 | 11 |
| 12 namespace gcm { | 12 namespace gcm { |
| 13 | 13 |
| 14 class GCMClientMock : public GCMClient { | 14 class GCMClientMock : public GCMClient { |
| 15 public: | 15 public: |
| 16 enum Status { | 16 enum Status { |
| 17 UNINITIALIZED, | 17 UNINITIALIZED, |
| 18 LOADED, | 18 STARTED, |
| 19 STOPPED, | 19 STOPPED, |
| 20 CHECKED_OUT | 20 CHECKED_OUT |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 enum LoadingDelay { | 23 enum StartMode { |
| 24 NO_DELAY_LOADING, | 24 NO_DELAY_START, |
| 25 DELAY_LOADING, | 25 DELAY_START, |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 // |loading_delay| denotes if the check-in should be delayed. | 28 explicit GCMClientMock(StartMode start_mode); |
| 29 explicit GCMClientMock(LoadingDelay loading_delay); | |
| 30 virtual ~GCMClientMock(); | 29 virtual ~GCMClientMock(); |
| 31 | 30 |
| 32 // Overridden from GCMClient: | 31 // Overridden from GCMClient: |
| 33 // Called on IO thread. | 32 // Called on IO thread. |
| 34 virtual void Initialize( | 33 virtual void Initialize( |
| 35 const checkin_proto::ChromeBuildProto& chrome_build_proto, | 34 const checkin_proto::ChromeBuildProto& chrome_build_proto, |
| 36 const base::FilePath& store_path, | 35 const base::FilePath& store_path, |
| 37 const std::vector<std::string>& account_ids, | 36 const std::vector<std::string>& account_ids, |
| 38 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, | 37 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner, |
| 39 const scoped_refptr<net::URLRequestContextGetter>& | 38 const scoped_refptr<net::URLRequestContextGetter>& |
| 40 url_request_context_getter, | 39 url_request_context_getter, |
| 41 Delegate* delegate) OVERRIDE; | 40 Delegate* delegate) OVERRIDE; |
| 42 virtual void Load() OVERRIDE; | 41 virtual void Start() OVERRIDE; |
| 43 virtual void Stop() OVERRIDE; | 42 virtual void Stop() OVERRIDE; |
| 44 virtual void CheckOut() OVERRIDE; | 43 virtual void CheckOut() OVERRIDE; |
| 45 virtual void Register(const std::string& app_id, | 44 virtual void Register(const std::string& app_id, |
| 46 const std::vector<std::string>& sender_ids) OVERRIDE; | 45 const std::vector<std::string>& sender_ids) OVERRIDE; |
| 47 virtual void Unregister(const std::string& app_id) OVERRIDE; | 46 virtual void Unregister(const std::string& app_id) OVERRIDE; |
| 48 virtual void Send(const std::string& app_id, | 47 virtual void Send(const std::string& app_id, |
| 49 const std::string& receiver_id, | 48 const std::string& receiver_id, |
| 50 const OutgoingMessage& message) OVERRIDE; | 49 const OutgoingMessage& message) OVERRIDE; |
| 51 virtual void SetRecording(bool recording) OVERRIDE; | 50 virtual void SetRecording(bool recording) OVERRIDE; |
| 52 virtual void ClearActivityLogs() OVERRIDE; | 51 virtual void ClearActivityLogs() OVERRIDE; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 76 void UnregisterFinished(const std::string& app_id); | 75 void UnregisterFinished(const std::string& app_id); |
| 77 void SendFinished(const std::string& app_id, const OutgoingMessage& message); | 76 void SendFinished(const std::string& app_id, const OutgoingMessage& message); |
| 78 void MessageReceived(const std::string& app_id, | 77 void MessageReceived(const std::string& app_id, |
| 79 const IncomingMessage& message); | 78 const IncomingMessage& message); |
| 80 void MessagesDeleted(const std::string& app_id); | 79 void MessagesDeleted(const std::string& app_id); |
| 81 void MessageSendError(const std::string& app_id, | 80 void MessageSendError(const std::string& app_id, |
| 82 const SendErrorDetails& send_error_details); | 81 const SendErrorDetails& send_error_details); |
| 83 | 82 |
| 84 Delegate* delegate_; | 83 Delegate* delegate_; |
| 85 Status status_; | 84 Status status_; |
| 86 LoadingDelay loading_delay_; | 85 StartMode start_mode_; |
| 87 base::WeakPtrFactory<GCMClientMock> weak_ptr_factory_; | 86 base::WeakPtrFactory<GCMClientMock> weak_ptr_factory_; |
| 88 | 87 |
| 89 DISALLOW_COPY_AND_ASSIGN(GCMClientMock); | 88 DISALLOW_COPY_AND_ASSIGN(GCMClientMock); |
| 90 }; | 89 }; |
| 91 | 90 |
| 92 } // namespace gcm | 91 } // namespace gcm |
| 93 | 92 |
| 94 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ | 93 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_ |
| OLD | NEW |