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

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

Issue 1232193002: Replace MessageLoop::current() with ThreadTaskRunnerHandle::Get() in GCM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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
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_message.h" 5 #include "google_apis/gcm/base/mcs_message.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/test/test_simple_task_runner.h"
9 #include "base/thread_task_runner_handle.h"
9 #include "google_apis/gcm/base/mcs_util.h" 10 #include "google_apis/gcm/base/mcs_util.h"
10 #include "google_apis/gcm/protocol/mcs.pb.h" 11 #include "google_apis/gcm/protocol/mcs.pb.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace gcm { 14 namespace gcm {
14 15
15 const uint64 kAndroidId = 12345; 16 const uint64 kAndroidId = 12345;
16 const uint64 kSecret = 54321; 17 const uint64 kSecret = 54321;
17 18
18 class MCSMessageTest : public testing::Test { 19 class MCSMessageTest : public testing::Test {
19 public: 20 public:
20 MCSMessageTest(); 21 MCSMessageTest();
21 ~MCSMessageTest() override; 22 ~MCSMessageTest() override;
22 23
23 private: 24 private:
24 base::MessageLoop message_loop_; 25 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
26 base::ThreadTaskRunnerHandle task_runner_handle_;
25 }; 27 };
26 28
27 MCSMessageTest::MCSMessageTest() { 29 MCSMessageTest::MCSMessageTest()
30 : task_runner_(new base::TestSimpleTaskRunner()),
31 task_runner_handle_(task_runner_) {
Nicolas Zea 2015/07/10 22:39:38 Do we need the handle here (and in the other tests
jianli 2015/07/10 23:04:15 Yes, this is to replace the task runner set in Mes
Nicolas Zea 2015/07/10 23:06:39 AFAICT this is just storing another reference to t
jianli 2015/07/10 23:11:43 This is to make ThreadTaskRunnerHandle::Get() work
28 } 32 }
29 33
30 MCSMessageTest::~MCSMessageTest() { 34 MCSMessageTest::~MCSMessageTest() {
31 } 35 }
32 36
33 TEST_F(MCSMessageTest, Invalid) { 37 TEST_F(MCSMessageTest, Invalid) {
34 MCSMessage message; 38 MCSMessage message;
35 EXPECT_FALSE(message.IsValid()); 39 EXPECT_FALSE(message.IsValid());
36 } 40 }
37 41
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 EXPECT_EQ(login_request->ByteSize(), message.size()); 87 EXPECT_EQ(login_request->ByteSize(), message.size());
84 EXPECT_EQ(login_request->SerializeAsString(), message.SerializeAsString()); 88 EXPECT_EQ(login_request->SerializeAsString(), message.SerializeAsString());
85 EXPECT_EQ(login_request->SerializeAsString(), 89 EXPECT_EQ(login_request->SerializeAsString(),
86 message.GetProtobuf().SerializeAsString()); 90 message.GetProtobuf().SerializeAsString());
87 login_copy = message.CloneProtobuf(); 91 login_copy = message.CloneProtobuf();
88 EXPECT_EQ(login_request->SerializeAsString(), 92 EXPECT_EQ(login_request->SerializeAsString(),
89 login_copy->SerializeAsString()); 93 login_copy->SerializeAsString());
90 } 94 }
91 95
92 } // namespace gcm 96 } // namespace gcm
OLDNEW
« no previous file with comments | « components/gcm_driver/gcm_channel_status_request_unittest.cc ('k') | google_apis/gcm/engine/checkin_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698