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 "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
10 #include "base/timer/timer.h" | 10 #include "base/timer/timer.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 FAIL(); | 44 FAIL(); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 void AppRemotingLatencyTestFixture::TearDown() { | 48 void AppRemotingLatencyTestFixture::TearDown() { |
49 connection_helper_.reset(); | 49 connection_helper_.reset(); |
50 } | 50 } |
51 | 51 |
52 void AppRemotingLatencyTestFixture::SetExpectedImagePattern( | 52 void AppRemotingLatencyTestFixture::SetExpectedImagePattern( |
53 const webrtc::DesktopRect& expected_rect, | 53 const webrtc::DesktopRect& expected_rect, |
54 const RgbaColor& expected_color) { | 54 uint32_t expected_color) { |
55 DCHECK(thread_checker_.CalledOnValidThread()); | 55 DCHECK(thread_checker_.CalledOnValidThread()); |
56 DCHECK(!run_loop_ || !run_loop_->running()); | 56 DCHECK(!run_loop_ || !run_loop_->running()); |
57 | 57 |
58 run_loop_.reset(new base::RunLoop()); | 58 run_loop_.reset(new base::RunLoop()); |
59 base::ThreadTaskRunnerHandle::Get()->PostTask( | 59 base::ThreadTaskRunnerHandle::Get()->PostTask( |
60 FROM_HERE, | 60 FROM_HERE, base::Bind(&TestVideoRenderer::ExpectAverageColorInRect, |
61 base::Bind(&TestVideoRenderer::SetImagePatternAndMatchedCallback, | 61 test_video_renderer_, expected_rect, expected_color, |
62 test_video_renderer_, expected_rect, expected_color, | 62 run_loop_->QuitClosure())); |
63 run_loop_->QuitClosure())); | |
64 } | 63 } |
65 | 64 |
66 bool AppRemotingLatencyTestFixture::WaitForImagePatternMatched( | 65 bool AppRemotingLatencyTestFixture::WaitForImagePatternMatched( |
67 const base::TimeDelta& max_wait_time) { | 66 const base::TimeDelta& max_wait_time) { |
68 DCHECK(thread_checker_.CalledOnValidThread()); | 67 DCHECK(thread_checker_.CalledOnValidThread()); |
69 DCHECK(run_loop_); | 68 DCHECK(run_loop_); |
70 | 69 |
71 DCHECK(!timer_->IsRunning()); | 70 DCHECK(!timer_->IsRunning()); |
72 timer_->Start(FROM_HERE, max_wait_time, run_loop_->QuitClosure()); | 71 timer_->Start(FROM_HERE, max_wait_time, run_loop_->QuitClosure()); |
73 | 72 |
74 run_loop_->Run(); | 73 run_loop_->Run(); |
75 | 74 |
76 // Image pattern is matched if we stopped because of the reply not the timer. | 75 // Image pattern is matched if we stopped because of the reply not the timer. |
77 bool image_pattern_is_matched = (timer_->IsRunning()); | 76 bool image_pattern_is_matched = (timer_->IsRunning()); |
78 timer_->Stop(); | 77 timer_->Stop(); |
79 run_loop_.reset(); | 78 run_loop_.reset(); |
80 | 79 |
81 return image_pattern_is_matched; | 80 return image_pattern_is_matched; |
82 } | 81 } |
83 | 82 |
84 } // namespace test | 83 } // namespace test |
85 } // namespace remoting | 84 } // namespace remoting |
OLD | NEW |