Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(921)

Side by Side Diff: chrome/browser/services/gcm/gcm_client_mock.h

Issue 284193005: Rename GCMClientMock to FakeGCMClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "google_apis/gcm/gcm_client.h"
11
12 namespace gcm {
13
14 class GCMClientMock : public GCMClient {
15 public:
16 enum Status {
17 UNINITIALIZED,
18 STARTED,
19 STOPPED,
20 CHECKED_OUT
21 };
22
23 enum StartMode {
24 NO_DELAY_START,
25 DELAY_START,
26 };
27
28 explicit GCMClientMock(StartMode start_mode);
29 virtual ~GCMClientMock();
30
31 // Overridden from GCMClient:
32 // Called on IO thread.
33 virtual void Initialize(
34 const checkin_proto::ChromeBuildProto& chrome_build_proto,
35 const base::FilePath& store_path,
36 const std::vector<std::string>& account_ids,
37 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
38 const scoped_refptr<net::URLRequestContextGetter>&
39 url_request_context_getter,
40 scoped_ptr<Encryptor> encryptor,
41 Delegate* delegate) OVERRIDE;
42 virtual void Start() OVERRIDE;
43 virtual void Stop() OVERRIDE;
44 virtual void CheckOut() OVERRIDE;
45 virtual void Register(const std::string& app_id,
46 const std::vector<std::string>& sender_ids) OVERRIDE;
47 virtual void Unregister(const std::string& app_id) OVERRIDE;
48 virtual void Send(const std::string& app_id,
49 const std::string& receiver_id,
50 const OutgoingMessage& message) OVERRIDE;
51 virtual void SetRecording(bool recording) OVERRIDE;
52 virtual void ClearActivityLogs() OVERRIDE;
53 virtual GCMStatistics GetStatistics() const OVERRIDE;
54
55 // Initiate the loading that has been delayed.
56 // Called on UI thread.
57 void PerformDelayedLoading();
58
59 // Simulate receiving something from the server.
60 // Called on UI thread.
61 void ReceiveMessage(const std::string& app_id,
62 const IncomingMessage& message);
63 void DeleteMessages(const std::string& app_id);
64
65 static std::string GetRegistrationIdFromSenderIds(
66 const std::vector<std::string>& sender_ids);
67
68 Status status() const { return status_; }
69
70 private:
71 // Called on IO thread.
72 void DoLoading();
73 void CheckinFinished();
74 void RegisterFinished(const std::string& app_id,
75 const std::string& registrion_id);
76 void UnregisterFinished(const std::string& app_id);
77 void SendFinished(const std::string& app_id, const OutgoingMessage& message);
78 void MessageReceived(const std::string& app_id,
79 const IncomingMessage& message);
80 void MessagesDeleted(const std::string& app_id);
81 void MessageSendError(const std::string& app_id,
82 const SendErrorDetails& send_error_details);
83
84 Delegate* delegate_;
85 Status status_;
86 StartMode start_mode_;
87 base::WeakPtrFactory<GCMClientMock> weak_ptr_factory_;
88
89 DISALLOW_COPY_AND_ASSIGN(GCMClientMock);
90 };
91
92 } // namespace gcm
93
94 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/fake_gcm_client_factory.cc ('k') | chrome/browser/services/gcm/gcm_client_mock.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698