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.
5 #ifndef CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_
6 #define CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_
8 #include "base/compiler_specific.h"
9 #include "google_apis/gcm/gcm_client.h"
13 class GCMClientMock : public GCMClient {
20 enum ErrorSimulation {
25 // |status| denotes if the fake client is ready or not at the beginning.
26 // |error_simulation| denotes if we should simulate server error.
27 GCMClientMock(Status status, ErrorSimulation error_simulation);
28 virtual ~GCMClientMock();
30 // Overridden from GCMClient:
31 // Called on IO thread.
32 virtual void Initialize(
33 const checkin_proto::ChromeBuildProto& chrome_build_proto,
34 const base::FilePath& store_path,
35 const scoped_refptr<base::SequencedTaskRunner>& blocking_task_runner,
36 const scoped_refptr<net::URLRequestContextGetter>&
37 url_request_context_getter,
38 Delegate* delegate) OVERRIDE;
39 virtual void CheckOut() OVERRIDE;
40 virtual void Register(const std::string& app_id,
41 const std::string& cert,
42 const std::vector<std::string>& sender_ids) OVERRIDE;
43 virtual void Unregister(const std::string& app_id) OVERRIDE;
44 virtual void Send(const std::string& app_id,
45 const std::string& receiver_id,
46 const OutgoingMessage& message) OVERRIDE;
47 virtual bool IsReady() const OVERRIDE;
49 // Simulate receiving something from the server.
50 // Called on UI thread.
51 void ReceiveMessage(const std::string& app_id,
52 const IncomingMessage& message);
53 void DeleteMessages(const std::string& app_id);
55 // Can only transition from non-ready to ready.
58 static std::string GetRegistrationIdFromSenderIds(
59 const std::vector<std::string>& sender_ids);
62 // Called on IO thread.
63 void RegisterFinished(const std::string& app_id,
64 const std::string& registrion_id);
65 void SendFinished(const std::string& app_id, const std::string& message_id);
66 void MessageReceived(const std::string& app_id,
67 const IncomingMessage& message);
68 void MessagesDeleted(const std::string& app_id);
69 void MessageSendError(const std::string& app_id,
70 const std::string& message_id);
75 ErrorSimulation error_simulation_;
77 DISALLOW_COPY_AND_ASSIGN(GCMClientMock);
82 #endif // CHROME_BROWSER_SERVICES_GCM_GCM_CLIENT_MOCK_H_