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_FAKE_GCM_PROFILE_SERVICE_H_
6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_
8 #include "chrome/browser/services/gcm/gcm_profile_service.h"
12 } // namespace content
16 // Acts as a bridge between GCM API and GCMClient layer for testing purposes.
17 class FakeGCMProfileService
: public GCMProfileService
{
19 // Helper function to be used with
20 // BrowserContextKeyedService::SetTestingFactory().
21 static BrowserContextKeyedService
* Build(content::BrowserContext
* context
);
23 static void EnableGCMForTesting();
25 explicit FakeGCMProfileService(Profile
* profile
);
26 virtual ~FakeGCMProfileService();
28 // GCMProfileService overrides.
29 virtual void Register(const std::string
& app_id
,
30 const std::vector
<std::string
>& sender_ids
,
31 const std::string
& cert
,
32 RegisterCallback callback
) OVERRIDE
;
33 virtual void Send(const std::string
& app_id
,
34 const std::string
& receiver_id
,
35 const GCMClient::OutgoingMessage
& message
,
36 SendCallback callback
) OVERRIDE
;
38 void RegisterFinished(const std::string
& app_id
,
39 const std::vector
<std::string
>& sender_ids
,
40 const std::string
& cert
,
41 RegisterCallback callback
);
43 void SendFinished(const std::string
& app_id
,
44 const std::string
& receiver_id
,
45 const GCMClient::OutgoingMessage
& message
,
46 SendCallback callback
);
48 const GCMClient::OutgoingMessage
& last_sent_message() const {
49 return last_sent_message_
;
52 const std::string
& last_receiver_id() const {
53 return last_receiver_id_
;
56 const std::string
& last_registered_app_id() const {
57 return last_registered_app_id_
;
60 const std::vector
<std::string
>& last_registered_sender_ids() const {
61 return last_registered_sender_ids_
;
64 const std::string
& last_registered_cert() const {
65 return last_registered_cert_
;
68 void set_collect(bool collect
) {
73 // Indicates whether the serivce will collect paramters of the calls for
74 // furter verification in tests.
76 std::string last_registered_app_id_
;
77 std::vector
<std::string
> last_registered_sender_ids_
;
78 std::string last_registered_cert_
;
79 GCMClient::OutgoingMessage last_sent_message_
;
80 std::string last_receiver_id_
;
82 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService
);
87 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_