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

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

Issue 270783002: [GCM] Add more UMA to GCM (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch to land 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
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/prefs/pref_service.h" 5 #include "base/prefs/pref_service.h"
6 #include "base/run_loop.h" 6 #include "base/run_loop.h"
7 #include "chrome/browser/extensions/api/gcm/gcm_api.h" 7 #include "chrome/browser/extensions/api/gcm/gcm_api.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_gcm_app_handler.h" 9 #include "chrome/browser/extensions/extension_gcm_app_handler.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendMessageData) { 145 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendMessageData) {
146 StartCollecting(); 146 StartCollecting();
147 ASSERT_TRUE(RunExtensionTest("gcm/functions/send_message_data")); 147 ASSERT_TRUE(RunExtensionTest("gcm/functions/send_message_data"));
148 148
149 EXPECT_EQ("destination-id", service()->last_receiver_id()); 149 EXPECT_EQ("destination-id", service()->last_receiver_id());
150 const gcm::GCMClient::OutgoingMessage& message = 150 const gcm::GCMClient::OutgoingMessage& message =
151 service()->last_sent_message(); 151 service()->last_sent_message();
152 gcm::GCMClient::MessageData::const_iterator iter; 152 gcm::GCMClient::MessageData::const_iterator iter;
153 153
154 EXPECT_EQ(100, message.time_to_live);
155
154 EXPECT_TRUE((iter = message.data.find("key1")) != message.data.end()); 156 EXPECT_TRUE((iter = message.data.find("key1")) != message.data.end());
155 EXPECT_EQ("value1", iter->second); 157 EXPECT_EQ("value1", iter->second);
156 158
157 EXPECT_TRUE((iter = message.data.find("key2")) != message.data.end()); 159 EXPECT_TRUE((iter = message.data.find("key2")) != message.data.end());
158 EXPECT_EQ("value2", iter->second); 160 EXPECT_EQ("value2", iter->second);
159 } 161 }
160 162
163 IN_PROC_BROWSER_TEST_F(GcmApiTest, SendMessageDefaultTTL) {
164 StartCollecting();
165 ASSERT_TRUE(RunExtensionTest("gcm/functions/send_message_default_ttl"));
166
167 EXPECT_EQ("destination-id", service()->last_receiver_id());
168 const gcm::GCMClient::OutgoingMessage& message =
169 service()->last_sent_message();
170 gcm::GCMClient::MessageData::const_iterator iter;
171
172 EXPECT_EQ(2419200, message.time_to_live);
173 }
174
161 IN_PROC_BROWSER_TEST_F(GcmApiTest, OnMessagesDeleted) { 175 IN_PROC_BROWSER_TEST_F(GcmApiTest, OnMessagesDeleted) {
162 ResultCatcher catcher; 176 ResultCatcher catcher;
163 catcher.RestrictToProfile(profile()); 177 catcher.RestrictToProfile(profile());
164 178
165 const extensions::Extension* extension = 179 const extensions::Extension* extension =
166 LoadTestExtension(kEventsExtension, "on_messages_deleted.html"); 180 LoadTestExtension(kEventsExtension, "on_messages_deleted.html");
167 ASSERT_TRUE(extension); 181 ASSERT_TRUE(extension);
168 182
169 extensions::ExtensionGCMAppHandler app_handler(profile()); 183 extensions::ExtensionGCMAppHandler app_handler(profile());
170 app_handler.OnMessagesDeleted(extension->id()); 184 app_handler.OnMessagesDeleted(extension->id());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ResultCatcher incognito_catcher; 253 ResultCatcher incognito_catcher;
240 incognito_catcher.RestrictToProfile(profile()->GetOffTheRecordProfile()); 254 incognito_catcher.RestrictToProfile(profile()->GetOffTheRecordProfile());
241 255
242 ASSERT_TRUE(RunExtensionTestIncognito("gcm/functions/incognito")); 256 ASSERT_TRUE(RunExtensionTestIncognito("gcm/functions/incognito"));
243 257
244 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message(); 258 EXPECT_TRUE(catcher.GetNextResult()) << catcher.message();
245 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message(); 259 EXPECT_TRUE(incognito_catcher.GetNextResult()) << incognito_catcher.message();
246 } 260 }
247 261
248 } // namespace extensions 262 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698