| 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/test/app_remoting_latency_test_fixture.h" | 5 #include "remoting/test/app_remoting_latency_test_fixture.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 namespace test { | 22 namespace test { |
| 23 | 23 |
| 24 AppRemotingLatencyTestFixture::AppRemotingLatencyTestFixture() | 24 AppRemotingLatencyTestFixture::AppRemotingLatencyTestFixture() |
| 25 : timer_(new base::Timer(true, false)) { | 25 : timer_(new base::Timer(true, false)) { |
| 26 // NOTE: Derived fixture must initialize application details in constructor. | 26 // NOTE: Derived fixture must initialize application details in constructor. |
| 27 } | 27 } |
| 28 | 28 |
| 29 AppRemotingLatencyTestFixture::~AppRemotingLatencyTestFixture() {} | 29 AppRemotingLatencyTestFixture::~AppRemotingLatencyTestFixture() {} |
| 30 | 30 |
| 31 void AppRemotingLatencyTestFixture::SetUp() { | 31 void AppRemotingLatencyTestFixture::SetUp() { |
| 32 scoped_ptr<TestVideoRenderer> test_video_renderer(new TestVideoRenderer()); | 32 std::unique_ptr<TestVideoRenderer> test_video_renderer( |
| 33 new TestVideoRenderer()); |
| 33 test_video_renderer_ = test_video_renderer->GetWeakPtr(); | 34 test_video_renderer_ = test_video_renderer->GetWeakPtr(); |
| 34 | 35 |
| 35 scoped_ptr<TestChromotingClient> test_chromoting_client( | 36 std::unique_ptr<TestChromotingClient> test_chromoting_client( |
| 36 new TestChromotingClient(std::move(test_video_renderer))); | 37 new TestChromotingClient(std::move(test_video_renderer))); |
| 37 | 38 |
| 38 test_chromoting_client->AddRemoteConnectionObserver(this); | 39 test_chromoting_client->AddRemoteConnectionObserver(this); |
| 39 | 40 |
| 40 connection_helper_.reset( | 41 connection_helper_.reset( |
| 41 new AppRemotingConnectionHelper(GetApplicationDetails())); | 42 new AppRemotingConnectionHelper(GetApplicationDetails())); |
| 42 connection_helper_->Initialize(std::move(test_chromoting_client)); | 43 connection_helper_->Initialize(std::move(test_chromoting_client)); |
| 43 | 44 |
| 44 if (!connection_helper_->StartConnection()) { | 45 if (!connection_helper_->StartConnection()) { |
| 45 LOG(ERROR) << "Remote host connection could not be established."; | 46 LOG(ERROR) << "Remote host connection could not be established."; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 60 | 61 |
| 61 connection_helper_->test_chromoting_client()->RemoveRemoteConnectionObserver( | 62 connection_helper_->test_chromoting_client()->RemoveRemoteConnectionObserver( |
| 62 this); | 63 this); |
| 63 connection_helper_.reset(); | 64 connection_helper_.reset(); |
| 64 } | 65 } |
| 65 | 66 |
| 66 WaitForImagePatternMatchCallback | 67 WaitForImagePatternMatchCallback |
| 67 AppRemotingLatencyTestFixture::SetExpectedImagePattern( | 68 AppRemotingLatencyTestFixture::SetExpectedImagePattern( |
| 68 const webrtc::DesktopRect& expected_rect, | 69 const webrtc::DesktopRect& expected_rect, |
| 69 const RGBValue& expected_color) { | 70 const RGBValue& expected_color) { |
| 70 scoped_ptr<base::RunLoop> run_loop(new base::RunLoop()); | 71 std::unique_ptr<base::RunLoop> run_loop(new base::RunLoop()); |
| 71 | 72 |
| 72 test_video_renderer_->ExpectAverageColorInRect(expected_rect, expected_color, | 73 test_video_renderer_->ExpectAverageColorInRect(expected_rect, expected_color, |
| 73 run_loop->QuitClosure()); | 74 run_loop->QuitClosure()); |
| 74 | 75 |
| 75 return base::Bind(&AppRemotingLatencyTestFixture::WaitForImagePatternMatch, | 76 return base::Bind(&AppRemotingLatencyTestFixture::WaitForImagePatternMatch, |
| 76 base::Unretained(this), base::Passed(&run_loop)); | 77 base::Unretained(this), base::Passed(&run_loop)); |
| 77 } | 78 } |
| 78 | 79 |
| 79 void AppRemotingLatencyTestFixture::SaveFrameDataToDisk( | 80 void AppRemotingLatencyTestFixture::SaveFrameDataToDisk( |
| 80 bool save_frame_data_to_disk) { | 81 bool save_frame_data_to_disk) { |
| 81 test_video_renderer_->SaveFrameDataToDisk(save_frame_data_to_disk); | 82 test_video_renderer_->SaveFrameDataToDisk(save_frame_data_to_disk); |
| 82 } | 83 } |
| 83 | 84 |
| 84 bool AppRemotingLatencyTestFixture::WaitForImagePatternMatch( | 85 bool AppRemotingLatencyTestFixture::WaitForImagePatternMatch( |
| 85 scoped_ptr<base::RunLoop> run_loop, | 86 std::unique_ptr<base::RunLoop> run_loop, |
| 86 const base::TimeDelta& max_wait_time) { | 87 const base::TimeDelta& max_wait_time) { |
| 87 DCHECK(run_loop); | 88 DCHECK(run_loop); |
| 88 DCHECK(!timer_->IsRunning()); | 89 DCHECK(!timer_->IsRunning()); |
| 89 | 90 |
| 90 timer_->Start(FROM_HERE, max_wait_time, run_loop->QuitClosure()); | 91 timer_->Start(FROM_HERE, max_wait_time, run_loop->QuitClosure()); |
| 91 | 92 |
| 92 run_loop->Run(); | 93 run_loop->Run(); |
| 93 | 94 |
| 94 // Image pattern is matched if we stopped because of the reply not the timer. | 95 // Image pattern is matched if we stopped because of the reply not the timer. |
| 95 bool image_pattern_is_matched = (timer_->IsRunning()); | 96 bool image_pattern_is_matched = (timer_->IsRunning()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 167 |
| 167 run_loop_.reset(new base::RunLoop()); | 168 run_loop_.reset(new base::RunLoop()); |
| 168 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 169 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 169 FROM_HERE, run_loop_->QuitClosure(), base::TimeDelta::FromSeconds(2)); | 170 FROM_HERE, run_loop_->QuitClosure(), base::TimeDelta::FromSeconds(2)); |
| 170 run_loop_->Run(); | 171 run_loop_->Run(); |
| 171 run_loop_.reset(); | 172 run_loop_.reset(); |
| 172 } | 173 } |
| 173 | 174 |
| 174 } // namespace test | 175 } // namespace test |
| 175 } // namespace remoting | 176 } // namespace remoting |
| OLD | NEW |