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

Side by Side Diff: google_apis/gcm/base/mcs_util_unittest.cc

Issue 171683002: [GCM] Fix gcm login to properly identify chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Self review Created 6 years, 10 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 "google_apis/gcm/base/mcs_util.h" 5 #include "google_apis/gcm/base/mcs_util.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace gcm { 13 namespace gcm {
14 namespace { 14 namespace {
15 15
16 const uint64 kAuthId = 4421448356646222460; 16 const uint64 kAuthId = 4421448356646222460;
17 const uint64 kAuthToken = 12345; 17 const uint64 kAuthToken = 12345;
18 18
19 // Build a login request protobuf. 19 // Build a login request protobuf.
20 TEST(MCSUtilTest, BuildLoginRequest) { 20 TEST(MCSUtilTest, BuildLoginRequest) {
21 std::vector<int64> user_serial_numbers; 21 std::vector<int64> user_serial_numbers;
22 user_serial_numbers.push_back(1LL); 22 user_serial_numbers.push_back(1LL);
23 user_serial_numbers.push_back(2LL); 23 user_serial_numbers.push_back(2LL);
24 scoped_ptr<mcs_proto::LoginRequest> login_request = 24 scoped_ptr<mcs_proto::LoginRequest> login_request =
25 BuildLoginRequest(kAuthId, kAuthToken, user_serial_numbers); 25 BuildLoginRequest(kAuthId, kAuthToken, "1.0", user_serial_numbers);
26 ASSERT_EQ("login-1", login_request->id()); 26 ASSERT_EQ("chrome-1.0", login_request->id());
27 ASSERT_EQ(base::Uint64ToString(kAuthToken), login_request->auth_token()); 27 ASSERT_EQ(base::Uint64ToString(kAuthToken), login_request->auth_token());
28 ASSERT_EQ(base::Uint64ToString(kAuthId), login_request->user()); 28 ASSERT_EQ(base::Uint64ToString(kAuthId), login_request->user());
29 ASSERT_EQ("android-3d5c23dac2a1fa7c", login_request->device_id()); 29 ASSERT_EQ("android-3d5c23dac2a1fa7c", login_request->device_id());
30 ASSERT_EQ("u:f", login_request->setting(0).name()); 30 ASSERT_EQ("u:f", login_request->setting(0).name());
31 ASSERT_EQ("1,2", login_request->setting(0).value()); 31 ASSERT_EQ("1,2", login_request->setting(0).value());
32 // TODO(zea): test the other fields once they have valid values. 32 // TODO(zea): test the other fields once they have valid values.
33 } 33 }
34 34
35 // Test building a protobuf and extracting the tag from a protobuf. 35 // Test building a protobuf and extracting the tag from a protobuf.
36 TEST(MCSUtilTest, ProtobufToTag) { 36 TEST(MCSUtilTest, ProtobufToTag) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 BuildProtobufFromTag(tag); 78 BuildProtobufFromTag(tag);
79 ASSERT_TRUE(protobuf.get()); 79 ASSERT_TRUE(protobuf.get());
80 SetLastStreamIdReceived(tag, protobuf.get()); 80 SetLastStreamIdReceived(tag, protobuf.get());
81 int get_id = GetLastStreamIdReceived(*protobuf); 81 int get_id = GetLastStreamIdReceived(*protobuf);
82 ASSERT_EQ(tag, get_id); 82 ASSERT_EQ(tag, get_id);
83 } 83 }
84 } 84 }
85 85
86 } // namespace 86 } // namespace
87 } // namespace gcm 87 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698