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_FAKE_GCM_PROFILE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ |
6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ | 6 #define CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ |
7 | 7 |
8 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 8 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 class BrowserContext; | 11 class BrowserContext; |
12 } // namespace content | 12 } // namespace content |
13 | 13 |
14 namespace gcm { | 14 namespace gcm { |
15 | 15 |
16 // Acts as a bridge between GCM API and GCMClient layer for testing purposes. | 16 // Acts as a bridge between GCM API and GCMClient layer for testing purposes. |
17 class FakeGCMProfileService : public GCMProfileService { | 17 class FakeGCMProfileService : public GCMProfileService { |
18 public: | 18 public: |
19 // Helper function to be used with | 19 // Helper function to be used with |
20 // BrowserContextKeyedService::SetTestingFactory(). | 20 // BrowserContextKeyedService::SetTestingFactory(). |
21 static BrowserContextKeyedService* Build(content::BrowserContext* context); | 21 static BrowserContextKeyedService* Build(content::BrowserContext* context); |
22 | 22 |
23 explicit FakeGCMProfileService(Profile* profile); | 23 explicit FakeGCMProfileService(Profile* profile); |
24 virtual ~FakeGCMProfileService(); | 24 virtual ~FakeGCMProfileService(); |
25 | 25 |
26 // GCMProfileService overrides. | 26 // GCMProfileService overrides. |
27 virtual void Register(const std::string& app_id, | 27 virtual void Register(const std::string& app_id, |
28 const std::vector<std::string>& sender_ids, | 28 const std::vector<std::string>& sender_ids, |
29 const std::string& cert, | |
30 RegisterCallback callback) OVERRIDE; | 29 RegisterCallback callback) OVERRIDE; |
31 virtual void Send(const std::string& app_id, | 30 virtual void Send(const std::string& app_id, |
32 const std::string& receiver_id, | 31 const std::string& receiver_id, |
33 const GCMClient::OutgoingMessage& message, | 32 const GCMClient::OutgoingMessage& message, |
34 SendCallback callback) OVERRIDE; | 33 SendCallback callback) OVERRIDE; |
35 | 34 |
36 void RegisterFinished(const std::string& app_id, | 35 void RegisterFinished(const std::string& app_id, |
37 const std::vector<std::string>& sender_ids, | 36 const std::vector<std::string>& sender_ids, |
38 const std::string& cert, | |
39 RegisterCallback callback); | 37 RegisterCallback callback); |
40 | 38 |
41 void SendFinished(const std::string& app_id, | 39 void SendFinished(const std::string& app_id, |
42 const std::string& receiver_id, | 40 const std::string& receiver_id, |
43 const GCMClient::OutgoingMessage& message, | 41 const GCMClient::OutgoingMessage& message, |
44 SendCallback callback); | 42 SendCallback callback); |
45 | 43 |
46 const GCMClient::OutgoingMessage& last_sent_message() const { | 44 const GCMClient::OutgoingMessage& last_sent_message() const { |
47 return last_sent_message_; | 45 return last_sent_message_; |
48 } | 46 } |
49 | 47 |
50 const std::string& last_receiver_id() const { | 48 const std::string& last_receiver_id() const { |
51 return last_receiver_id_; | 49 return last_receiver_id_; |
52 } | 50 } |
53 | 51 |
54 const std::string& last_registered_app_id() const { | 52 const std::string& last_registered_app_id() const { |
55 return last_registered_app_id_; | 53 return last_registered_app_id_; |
56 } | 54 } |
57 | 55 |
58 const std::vector<std::string>& last_registered_sender_ids() const { | 56 const std::vector<std::string>& last_registered_sender_ids() const { |
59 return last_registered_sender_ids_; | 57 return last_registered_sender_ids_; |
60 } | 58 } |
61 | 59 |
62 const std::string& last_registered_cert() const { | |
63 return last_registered_cert_; | |
64 } | |
65 | |
66 void set_collect(bool collect) { | 60 void set_collect(bool collect) { |
67 collect_ = collect; | 61 collect_ = collect; |
68 } | 62 } |
69 | 63 |
70 private: | 64 private: |
71 // Indicates whether the serivce will collect paramters of the calls for | 65 // Indicates whether the serivce will collect paramters of the calls for |
72 // furter verification in tests. | 66 // furter verification in tests. |
73 bool collect_; | 67 bool collect_; |
74 std::string last_registered_app_id_; | 68 std::string last_registered_app_id_; |
75 std::vector<std::string> last_registered_sender_ids_; | 69 std::vector<std::string> last_registered_sender_ids_; |
76 std::string last_registered_cert_; | |
77 GCMClient::OutgoingMessage last_sent_message_; | 70 GCMClient::OutgoingMessage last_sent_message_; |
78 std::string last_receiver_id_; | 71 std::string last_receiver_id_; |
79 | 72 |
80 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); | 73 DISALLOW_COPY_AND_ASSIGN(FakeGCMProfileService); |
81 }; | 74 }; |
82 | 75 |
83 } // namespace gcm | 76 } // namespace gcm |
84 | 77 |
85 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ | 78 #endif // CHROME_BROWSER_SERVICES_GCM_FAKE_GCM_PROFILE_SERVICE_H_ |
OLD | NEW |