| OLD | NEW |
| 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 <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 class GcdStateUpdaterTest : public testing::Test { | 29 class GcdStateUpdaterTest : public testing::Test { |
| 30 public: | 30 public: |
| 31 GcdStateUpdaterTest() | 31 GcdStateUpdaterTest() |
| 32 : task_runner_(new base::TestMockTimeTaskRunner()), | 32 : task_runner_(new base::TestMockTimeTaskRunner()), |
| 33 runner_handler_(task_runner_), | 33 runner_handler_(task_runner_), |
| 34 clock_(task_runner_->GetMockClock()), | 34 clock_(task_runner_->GetMockClock()), |
| 35 token_getter_(OAuthTokenGetter::SUCCESS, | 35 token_getter_(OAuthTokenGetter::SUCCESS, |
| 36 "<fake_user_email>", | 36 "<fake_user_email>", |
| 37 "<fake_access_token>"), | 37 "<fake_access_token>"), |
| 38 rest_client_(new GcdRestClient( | 38 rest_client_(new GcdRestClient("http://gcd_base_url", |
| 39 "http://gcd_base_url", | 39 "<gcd_device_id>", |
| 40 "<gcd_device_id>", | 40 nullptr, |
| 41 nullptr, | 41 &token_getter_)), |
| 42 &token_getter_)), | 42 signal_strategy_(SignalingAddress("local_jid")) { |
| 43 signal_strategy_("local_jid") { | |
| 44 rest_client_->SetClockForTest(base::WrapUnique(new base::SimpleTestClock)); | 43 rest_client_->SetClockForTest(base::WrapUnique(new base::SimpleTestClock)); |
| 45 } | 44 } |
| 46 | 45 |
| 47 void OnSuccess() { on_success_count_++; } | 46 void OnSuccess() { on_success_count_++; } |
| 48 | 47 |
| 49 void OnHostIdError() { on_host_id_error_count_++; } | 48 void OnHostIdError() { on_host_id_error_count_++; } |
| 50 | 49 |
| 51 protected: | 50 protected: |
| 52 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; | 51 scoped_refptr<base::TestMockTimeTaskRunner> task_runner_; |
| 53 base::ThreadTaskRunnerHandle runner_handler_; | 52 base::ThreadTaskRunnerHandle runner_handler_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), | 88 base::Bind(&GcdStateUpdaterTest::OnSuccess, base::Unretained(this)), |
| 90 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), | 89 base::Bind(&GcdStateUpdaterTest::OnHostIdError, base::Unretained(this)), |
| 91 &signal_strategy_, std::move(rest_client_))); | 90 &signal_strategy_, std::move(rest_client_))); |
| 92 | 91 |
| 93 // Connect, then re-connect with a different JID while the status | 92 // Connect, then re-connect with a different JID while the status |
| 94 // update for the first connection is pending. | 93 // update for the first connection is pending. |
| 95 signal_strategy_.Connect(); | 94 signal_strategy_.Connect(); |
| 96 task_runner_->RunUntilIdle(); | 95 task_runner_->RunUntilIdle(); |
| 97 signal_strategy_.Disconnect(); | 96 signal_strategy_.Disconnect(); |
| 98 task_runner_->RunUntilIdle(); | 97 task_runner_->RunUntilIdle(); |
| 99 signal_strategy_.SetLocalJid("local_jid2"); | 98 signal_strategy_.SetLocalAddress(SignalingAddress("local_jid2")); |
| 100 signal_strategy_.Connect(); | 99 signal_strategy_.Connect(); |
| 101 task_runner_->RunUntilIdle(); | 100 task_runner_->RunUntilIdle(); |
| 102 | 101 |
| 103 // Let the first status update finish. This should be a no-op in | 102 // Let the first status update finish. This should be a no-op in |
| 104 // the updater because the local JID has changed since this request | 103 // the updater because the local JID has changed since this request |
| 105 // was issued. | 104 // was issued. |
| 106 net::TestURLFetcher* fetcher0 = url_fetcher_factory_.GetFetcherByID(0); | 105 net::TestURLFetcher* fetcher0 = url_fetcher_factory_.GetFetcherByID(0); |
| 107 fetcher0->set_response_code(200); | 106 fetcher0->set_response_code(200); |
| 108 fetcher0->delegate()->OnURLFetchComplete(fetcher0); | 107 fetcher0->delegate()->OnURLFetchComplete(fetcher0); |
| 109 EXPECT_EQ(0, on_success_count_); | 108 EXPECT_EQ(0, on_success_count_); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 task_runner_->RunUntilIdle(); | 162 task_runner_->RunUntilIdle(); |
| 164 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); | 163 net::TestURLFetcher* fetcher = url_fetcher_factory_.GetFetcherByID(0); |
| 165 ASSERT_TRUE(fetcher); | 164 ASSERT_TRUE(fetcher); |
| 166 fetcher->set_response_code(404); | 165 fetcher->set_response_code(404); |
| 167 fetcher->delegate()->OnURLFetchComplete(fetcher); | 166 fetcher->delegate()->OnURLFetchComplete(fetcher); |
| 168 EXPECT_EQ(0, on_success_count_); | 167 EXPECT_EQ(0, on_success_count_); |
| 169 EXPECT_EQ(1, on_host_id_error_count_); | 168 EXPECT_EQ(1, on_host_id_error_count_); |
| 170 } | 169 } |
| 171 | 170 |
| 172 } // namespace remoting | 171 } // namespace remoting |
| OLD | NEW |