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

Side by Side Diff: remoting/host/gcd_state_updater_unittest.cc

Issue 1549493004: Use std::move() instead of .Pass() in remoting/host (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass
Patch Set: include <utility> Created 4 years, 12 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
« no previous file with comments | « remoting/host/gcd_state_updater.cc ('k') | remoting/host/gnubby_auth_handler_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "remoting/host/gcd_state_updater.h" 5 #include "remoting/host/gcd_state_updater.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/strings/stringize_macros.h" 11 #include "base/strings/stringize_macros.h"
11 #include "base/test/simple_test_clock.h" 12 #include "base/test/simple_test_clock.h"
12 #include "base/test/test_mock_time_task_runner.h" 13 #include "base/test/test_mock_time_task_runner.h"
13 #include "base/thread_task_runner_handle.h" 14 #include "base/thread_task_runner_handle.h"
14 #include "net/url_request/test_url_fetcher_factory.h" 15 #include "net/url_request/test_url_fetcher_factory.h"
15 #include "remoting/base/constants.h" 16 #include "remoting/base/constants.h"
16 #include "remoting/host/fake_oauth_token_getter.h" 17 #include "remoting/host/fake_oauth_token_getter.h"
17 #include "remoting/host/gcd_rest_client.h" 18 #include "remoting/host/gcd_rest_client.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 scoped_ptr<GcdRestClient> rest_client_; 56 scoped_ptr<GcdRestClient> rest_client_;
56 FakeSignalStrategy signal_strategy_; 57 FakeSignalStrategy signal_strategy_;
57 int on_success_count_ = 0; 58 int on_success_count_ = 0;
58 int on_host_id_error_count_ = 0; 59 int on_host_id_error_count_ = 0;
59 }; 60 };
60 61
61 TEST_F(GcdStateUpdaterTest, Success) { 62 TEST_F(GcdStateUpdaterTest, Success) {
62 scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater( 63 scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater(
63 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), 64 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)),
64 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), 65 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)),
65 &signal_strategy_, rest_client_.Pass())); 66 &signal_strategy_, std::move(rest_client_)));
66 67
67 signal_strategy_.Connect(); 68 signal_strategy_.Connect();
68 task_runner_->RunUntilIdle(); 69 task_runner_->RunUntilIdle();
69 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 70 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
70 ASSERT_TRUE(fetcher); 71 ASSERT_TRUE(fetcher);
71 EXPECT_EQ("{\"patches\":[{\"patch\":{" 72 EXPECT_EQ("{\"patches\":[{\"patch\":{"
72 "\"base\":{\"_hostVersion\":\"" STRINGIZE(VERSION) "\"," 73 "\"base\":{\"_hostVersion\":\"" STRINGIZE(VERSION) "\","
73 "\"_jabberId\":\"local_jid\"}}," 74 "\"_jabberId\":\"local_jid\"}},"
74 "\"timeMs\":0.0}],\"requestTimeMs\":0.0}", 75 "\"timeMs\":0.0}],\"requestTimeMs\":0.0}",
75 fetcher->upload_data()); 76 fetcher->upload_data());
76 fetcher->set_response_code(200); 77 fetcher->set_response_code(200);
77 fetcher->delegate()->OnURLFetchComplete(fetcher); 78 fetcher->delegate()->OnURLFetchComplete(fetcher);
78 EXPECT_EQ(1, on_success_count_); 79 EXPECT_EQ(1, on_success_count_);
79 80
80 updater.reset(); 81 updater.reset();
81 82
82 EXPECT_EQ(0, on_host_id_error_count_); 83 EXPECT_EQ(0, on_host_id_error_count_);
83 } 84 }
84 85
85 TEST_F(GcdStateUpdaterTest, QueuedRequests) { 86 TEST_F(GcdStateUpdaterTest, QueuedRequests) {
86 scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater( 87 scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater(
87 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), 88 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)),
88 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), 89 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)),
89 &signal_strategy_, rest_client_.Pass())); 90 &signal_strategy_, std::move(rest_client_)));
90 91
91 // Connect, then re-connect with a different JID while the status 92 // Connect, then re-connect with a different JID while the status
92 // update for the first connection is pending. 93 // update for the first connection is pending.
93 signal_strategy_.Connect(); 94 signal_strategy_.Connect();
94 task_runner_->RunUntilIdle(); 95 task_runner_->RunUntilIdle();
95 signal_strategy_.Disconnect(); 96 signal_strategy_.Disconnect();
96 task_runner_->RunUntilIdle(); 97 task_runner_->RunUntilIdle();
97 signal_strategy_.SetLocalJid("local_jid2"); 98 signal_strategy_.SetLocalJid("local_jid2");
98 signal_strategy_.Connect(); 99 signal_strategy_.Connect();
99 task_runner_->RunUntilIdle(); 100 task_runner_->RunUntilIdle();
(...skipping 23 matching lines...) Expand all
123 124
124 updater.reset(); 125 updater.reset();
125 126
126 EXPECT_EQ(0, on_host_id_error_count_); 127 EXPECT_EQ(0, on_host_id_error_count_);
127 } 128 }
128 129
129 TEST_F(GcdStateUpdaterTest, Retry) { 130 TEST_F(GcdStateUpdaterTest, Retry) {
130 scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater( 131 scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater(
131 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), 132 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)),
132 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), 133 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)),
133 &signal_strategy_, rest_client_.Pass())); 134 &signal_strategy_, std::move(rest_client_)));
134 135
135 signal_strategy_.Connect(); 136 signal_strategy_.Connect();
136 task_runner_->RunUntilIdle(); 137 task_runner_->RunUntilIdle();
137 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 138 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
138 ASSERT_TRUE(fetcher); 139 ASSERT_TRUE(fetcher);
139 fetcher->set_response_code(0); 140 fetcher->set_response_code(0);
140 fetcher->delegate()->OnURLFetchComplete(fetcher); 141 fetcher->delegate()->OnURLFetchComplete(fetcher);
141 task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(1)); 142 task_runner_->FastForwardBy(base::TimeDelta::FromSeconds(1));
142 EXPECT_EQ(1.0, clock_->Now().ToDoubleT()); 143 EXPECT_EQ(1.0, clock_->Now().ToDoubleT());
143 fetcher = url_fetcher_factory_.GetFetcherByID(0); 144 fetcher = url_fetcher_factory_.GetFetcherByID(0);
144 ASSERT_TRUE(fetcher); 145 ASSERT_TRUE(fetcher);
145 fetcher->set_response_code(200); 146 fetcher->set_response_code(200);
146 fetcher->delegate()->OnURLFetchComplete(fetcher); 147 fetcher->delegate()->OnURLFetchComplete(fetcher);
147 EXPECT_EQ(1, on_success_count_); 148 EXPECT_EQ(1, on_success_count_);
148 149
149 updater.reset(); 150 updater.reset();
150 151
151 EXPECT_EQ(0, on_host_id_error_count_); 152 EXPECT_EQ(0, on_host_id_error_count_);
152 } 153 }
153 154
154 TEST_F(GcdStateUpdaterTest, UnknownHost) { 155 TEST_F(GcdStateUpdaterTest, UnknownHost) {
155 scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater( 156 scoped_ptr<GcdStateUpdater> updater(new GcdStateUpdater(
156 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), 157 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)),
157 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), 158 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)),
158 &signal_strategy_, rest_client_.Pass())); 159 &signal_strategy_, std::move(rest_client_)));
159 160
160 signal_strategy_.Connect(); 161 signal_strategy_.Connect();
161 task_runner_->RunUntilIdle(); 162 task_runner_->RunUntilIdle();
162 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); 163 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0);
163 ASSERT_TRUE(fetcher); 164 ASSERT_TRUE(fetcher);
164 fetcher->set_response_code(404); 165 fetcher->set_response_code(404);
165 fetcher->delegate()->OnURLFetchComplete(fetcher); 166 fetcher->delegate()->OnURLFetchComplete(fetcher);
166 EXPECT_EQ(0, on_success_count_); 167 EXPECT_EQ(0, on_success_count_);
167 EXPECT_EQ(1, on_host_id_error_count_); 168 EXPECT_EQ(1, on_host_id_error_count_);
168 } 169 }
169 170
170 } // namespace remoting 171 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/gcd_state_updater.cc ('k') | remoting/host/gnubby_auth_handler_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698