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

Side by Side Diff: chrome/browser/extensions/api/gcm/gcm_apitest.cc

Issue 126913002: Enable most of GCM API tests on Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "chrome/browser/extensions/api/gcm/gcm_api.h" 6 #include "chrome/browser/extensions/api/gcm/gcm_api.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h" 9 #include "chrome/browser/services/gcm/fake_gcm_profile_service.h"
10 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 10 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
11 #include "chrome/common/extensions/features/feature_channel.h"
11 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
12 13
13 namespace { 14 namespace {
14 15
15 const char kFunctionsTestExtension[] = "gcm/functions"; 16 const char kFunctionsTestExtension[] = "gcm/functions";
16 const char kEventsExtension[] = "gcm/events"; 17 const char kEventsExtension[] = "gcm/events";
17 18
18 } // namespace 19 } // namespace
19 20
20 namespace extensions { 21 namespace extensions {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 run_loop.RunUntilIdle(); 57 run_loop.RunUntilIdle();
57 } 58 }
58 59
59 gcm::FakeGCMProfileService* GcmApiTest::service() const { 60 gcm::FakeGCMProfileService* GcmApiTest::service() const {
60 return fake_gcm_profile_service_; 61 return fake_gcm_profile_service_;
61 } 62 }
62 63
63 const Extension* GcmApiTest::LoadTestExtension( 64 const Extension* GcmApiTest::LoadTestExtension(
64 const std::string& extension_path, 65 const std::string& extension_path,
65 const std::string& page_name) { 66 const std::string& page_name) {
67 // TODO(jianli): Once the GCM API enters stable, remove |channel|.
68 ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_UNKNOWN);
66 const Extension* extension = 69 const Extension* extension =
67 LoadExtension(test_data_dir_.AppendASCII(extension_path)); 70 LoadExtension(test_data_dir_.AppendASCII(extension_path));
68 if (extension) { 71 if (extension) {
69 ui_test_utils::NavigateToURL( 72 ui_test_utils::NavigateToURL(
70 browser(), extension->GetResourceURL(page_name)); 73 browser(), extension->GetResourceURL(page_name));
71 } 74 }
72 return extension; 75 return extension;
73 } 76 }
74 77
75 // http://crbug.com/177163 and http://crbug.com/324982 78 // http://crbug.com/177163
76 #if defined(OS_WIN) 79 #if defined(OS_WIN)
77 #define MAYBE_RegisterValidation DISABLED_RegisterValidation 80 #define MAYBE_RegisterValidation DISABLED_RegisterValidation
78 #else 81 #else
79 #define MAYBE_RegisterValidation RegisterValidation 82 #define MAYBE_RegisterValidation RegisterValidation
80 #endif 83 #endif
81 IN_PROC_BROWSER_TEST_F(GcmApiTest, MAYBE_RegisterValidation) { 84 IN_PROC_BROWSER_TEST_F(GcmApiTest, MAYBE_RegisterValidation) {
82 EXPECT_TRUE(RunExtensionSubtest(kFunctionsTestExtension, 85 EXPECT_TRUE(RunExtensionSubtest(kFunctionsTestExtension,
83 "register_validation.html")); 86 "register_validation.html"));
84 } 87 }
85 88
86 // http://crbug.com/177163 and http://crbug.com/324982 89 IN_PROC_BROWSER_TEST_F(GcmApiTest, Register) {
87 #if defined(OS_WIN)
88 #define MAYBE_Register DISABLED_Register
89 #else
90 #define MAYBE_Register Register
91 #endif
92 IN_PROC_BROWSER_TEST_F(GcmApiTest, MAYBE_Register) {
93 StartCollecting(); 90 StartCollecting();
94 const extensions::Extension* extension = 91 const extensions::Extension* extension =
95 LoadTestExtension(kFunctionsTestExtension, "register.html"); 92 LoadTestExtension(kFunctionsTestExtension, "register.html");
96 ASSERT_TRUE(extension); 93 ASSERT_TRUE(extension);
97 94
98 WaitUntilIdle(); 95 WaitUntilIdle();
99 96
100 EXPECT_EQ(extension->id(), service()->last_registered_app_id()); 97 EXPECT_EQ(extension->id(), service()->last_registered_app_id());
101 // SHA1 of the public key provided in manifest.json. 98 // SHA1 of the public key provided in manifest.json.
102 EXPECT_EQ("26469186F238EE08FA71C38311C6990F61D40DCA", 99 EXPECT_EQ("26469186F238EE08FA71C38311C6990F61D40DCA",
103 service()->last_registered_cert()); 100 service()->last_registered_cert());
104 const std::vector<std::string>& sender_ids = 101 const std::vector<std::string>& sender_ids =
105 service()->last_registered_sender_ids(); 102 service()->last_registered_sender_ids();
106 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender1") != 103 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender1") !=
107 sender_ids.end()); 104 sender_ids.end());
108 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender2") != 105 EXPECT_TRUE(std::find(sender_ids.begin(), sender_ids.end(), "Sender2") !=
109 sender_ids.end()); 106 sender_ids.end());
110 } 107 }
111 108
112 // http://crbug.com/177163 and http://crbug.com/324982 109 // http://crbug.com/177163
113 #if defined(OS_WIN) 110 #if defined(OS_WIN)
114 #define MAYBE_SendValidation DISABLED_SendValidation 111 #define MAYBE_SendValidation DISABLED_SendValidation
115 #else 112 #else
116 #define MAYBE_SendValidation SendValidation 113 #define MAYBE_SendValidation SendValidation
117 #endif 114 #endif
118 IN_PROC_BROWSER_TEST_F(GcmApiTest, MAYBE_SendValidation) { 115 IN_PROC_BROWSER_TEST_F(GcmApiTest, MAYBE_SendValidation) {
119 EXPECT_TRUE(RunExtensionSubtest(kFunctionsTestExtension, "send.html")); 116 EXPECT_TRUE(RunExtensionSubtest(kFunctionsTestExtension, "send.html"));
120 } 117 }
121 118
122 // http://crbug.com/177163 and http://crbug.com/324982 119 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendMessageData) {
123 #if defined(OS_WIN)
124 #define MAYBE_SendMessageData DISABLED_SendMessageData
125 #else
126 #define MAYBE_SendMessageData SendMessageData
127 #endif
128 IN_PROC_BROWSER_TEST_F(GcmApiTest, MAYBE_SendMessageData) {
129 StartCollecting(); 120 StartCollecting();
130 const extensions::Extension* extension = 121 const extensions::Extension* extension =
131 LoadTestExtension(kFunctionsTestExtension, "send_message_data.html"); 122 LoadTestExtension(kFunctionsTestExtension, "send_message_data.html");
132 ASSERT_TRUE(extension); 123 ASSERT_TRUE(extension);
133 124
134 WaitUntilIdle(); 125 WaitUntilIdle();
135 126
136 EXPECT_EQ("destination-id", service()->last_receiver_id()); 127 EXPECT_EQ("destination-id", service()->last_receiver_id());
137 const gcm::GCMClient::OutgoingMessage& message = 128 const gcm::GCMClient::OutgoingMessage& message =
138 service()->last_sent_message(); 129 service()->last_sent_message();
139 gcm::GCMClient::MessageData::const_iterator iter; 130 gcm::GCMClient::MessageData::const_iterator iter;
140 131
141 EXPECT_TRUE((iter = message.data.find("key1")) != message.data.end()); 132 EXPECT_TRUE((iter = message.data.find("key1")) != message.data.end());
142 EXPECT_EQ("value1", iter->second); 133 EXPECT_EQ("value1", iter->second);
143 134
144 EXPECT_TRUE((iter = message.data.find("key2")) != message.data.end()); 135 EXPECT_TRUE((iter = message.data.find("key2")) != message.data.end());
145 EXPECT_EQ("value2", iter->second); 136 EXPECT_EQ("value2", iter->second);
146 } 137 }
147 138
148 // http://crbug.com/177163 and http://crbug/324982 139 IN_PROC_BROWSER_TEST_F(GcmApiTest, OnMessagesDeleted) {
149 #if defined(OS_WIN) && !defined(NDEBUG)
150 #define MAYBE_OnMessagesDeleted DISABLED_OnMessagesDeleted
151 #else
152 #define MAYBE_OnMessagesDeleted OnMessagesDeleted
153 #endif
154 IN_PROC_BROWSER_TEST_F(GcmApiTest, MAYBE_OnMessagesDeleted) {
155 ResultCatcher catcher; 140 ResultCatcher catcher;
156 catcher.RestrictToProfile(profile()); 141 catcher.RestrictToProfile(profile());
157 142
158 const extensions::Extension* extension = 143 const extensions::Extension* extension =
159 LoadTestExtension(kEventsExtension, "on_messages_deleted.html"); 144 LoadTestExtension(kEventsExtension, "on_messages_deleted.html");
160 ASSERT_TRUE(extension); 145 ASSERT_TRUE(extension);
161 146
162 GcmJsEventRouter router(profile()); 147 GcmJsEventRouter router(profile());
163 router.OnMessagesDeleted(extension->id()); 148 router.OnMessagesDeleted(extension->id());
164 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 149 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
165 } 150 }
166 151
167 // http://crbug.com/177163 and http://crbug/324982 152 IN_PROC_BROWSER_TEST_F(GcmApiTest, OnMessage) {
168 #if defined(OS_WIN) && !defined(NDEBUG)
169 #define MAYBE_OnMessage DISABLED_OnMessage
170 #else
171 #define MAYBE_OnMessage OnMessage
172 #endif
173 IN_PROC_BROWSER_TEST_F(GcmApiTest, MAYBE_OnMessage) {
174 ResultCatcher catcher; 153 ResultCatcher catcher;
175 catcher.RestrictToProfile(profile()); 154 catcher.RestrictToProfile(profile());
176 155
177 const extensions::Extension* extension = 156 const extensions::Extension* extension =
178 LoadTestExtension(kEventsExtension, "on_message.html"); 157 LoadTestExtension(kEventsExtension, "on_message.html");
179 ASSERT_TRUE(extension); 158 ASSERT_TRUE(extension);
180 159
181 GcmJsEventRouter router(profile()); 160 GcmJsEventRouter router(profile());
182 161
183 gcm::GCMClient::IncomingMessage message; 162 gcm::GCMClient::IncomingMessage message;
184 message.data["property1"] = "value1"; 163 message.data["property1"] = "value1";
185 message.data["property2"] = "value2"; 164 message.data["property2"] = "value2";
186 router.OnMessage(extension->id(), message); 165 router.OnMessage(extension->id(), message);
187 166
188 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 167 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
189 } 168 }
190 169
191 // http://crbug.com/177163 and http://crbug/324982 170 IN_PROC_BROWSER_TEST_F(GcmApiTest, OnSendError) {
192 #if defined(OS_WIN) && !defined(NDEBUG)
193 #define MAYBE_OnSendError DISABLED_OnSendError
194 #else
195 #define MAYBE_OnSendError OnSendError
196 #endif
197 IN_PROC_BROWSER_TEST_F(GcmApiTest, MAYBE_OnSendError) {
198 ResultCatcher catcher; 171 ResultCatcher catcher;
199 catcher.RestrictToProfile(profile()); 172 catcher.RestrictToProfile(profile());
200 173
201 const extensions::Extension* extension = 174 const extensions::Extension* extension =
202 LoadTestExtension(kEventsExtension, "on_send_error.html"); 175 LoadTestExtension(kEventsExtension, "on_send_error.html");
203 ASSERT_TRUE(extension); 176 ASSERT_TRUE(extension);
204 177
205 GcmJsEventRouter router(profile()); 178 GcmJsEventRouter router(profile());
206 router.OnSendError(extension->id(), "error_message_1", 179 router.OnSendError(extension->id(), "error_message_1",
207 gcm::GCMClient::ASYNC_OPERATION_PENDING); 180 gcm::GCMClient::ASYNC_OPERATION_PENDING);
208 router.OnSendError(extension->id(), "error_message_2", 181 router.OnSendError(extension->id(), "error_message_2",
209 gcm::GCMClient::SERVER_ERROR); 182 gcm::GCMClient::SERVER_ERROR);
210 router.OnSendError(extension->id(), "error_message_3", 183 router.OnSendError(extension->id(), "error_message_3",
211 gcm::GCMClient::NETWORK_ERROR); 184 gcm::GCMClient::NETWORK_ERROR);
212 router.OnSendError(extension->id(), "error_message_4", 185 router.OnSendError(extension->id(), "error_message_4",
213 gcm::GCMClient::UNKNOWN_ERROR); 186 gcm::GCMClient::UNKNOWN_ERROR);
214 router.OnSendError(extension->id(), "error_message_5", 187 router.OnSendError(extension->id(), "error_message_5",
215 gcm::GCMClient::TTL_EXCEEDED); 188 gcm::GCMClient::TTL_EXCEEDED);
216 189
217 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 190 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
218 } 191 }
219 192
220 } // namespace extensions 193 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698