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

Side by Side Diff: remoting/test/app_remoting_latency_test_fixture.cc

Issue 1253613002: Updated latency fixture and refactored connection helper (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 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 18 matching lines...) Expand all
29 29
30 void AppRemotingLatencyTestFixture::SetUp() { 30 void AppRemotingLatencyTestFixture::SetUp() {
31 DCHECK(thread_checker_.CalledOnValidThread()); 31 DCHECK(thread_checker_.CalledOnValidThread());
32 32
33 scoped_ptr<TestVideoRenderer> test_video_renderer(new TestVideoRenderer()); 33 scoped_ptr<TestVideoRenderer> test_video_renderer(new TestVideoRenderer());
34 test_video_renderer_ = test_video_renderer->GetWeakPtr(); 34 test_video_renderer_ = test_video_renderer->GetWeakPtr();
35 35
36 scoped_ptr<TestChromotingClient> test_chromoting_client( 36 scoped_ptr<TestChromotingClient> test_chromoting_client(
37 new TestChromotingClient(test_video_renderer.Pass())); 37 new TestChromotingClient(test_video_renderer.Pass()));
38 38
39 test_chromoting_client_ = test_chromoting_client->GetWeakPtr();
40
41 test_chromoting_client_->AddRemoteConnectionObserver(this);
42
39 connection_helper_.reset( 43 connection_helper_.reset(
40 new AppRemotingConnectionHelper(GetApplicationDetails())); 44 new AppRemotingConnectionHelper(GetApplicationDetails()));
41 connection_helper_->Initialize(test_chromoting_client.Pass()); 45 connection_helper_->Initialize(test_chromoting_client.Pass());
42 46
43 if (!connection_helper_->StartConnection()) { 47 if (!connection_helper_->StartConnection()) {
44 LOG(ERROR) << "Remote host connection could not be established."; 48 LOG(ERROR) << "Remote host connection could not be established.";
45 FAIL(); 49 FAIL();
46 } 50 }
51
52 if (!CreateNewDocument()) {
53 LOG(ERROR) << "New document could not be created.";
54 FAIL();
joedow 2015/07/23 20:26:56 Have you run this through the try-bots yet? I see
liaoyuke 2015/07/24 02:07:28 Yeah, I'll run try-bots on my next patch.
55 }
47 } 56 }
48 57
49 void AppRemotingLatencyTestFixture::TearDown() { 58 void AppRemotingLatencyTestFixture::TearDown() {
50 // Only reset application state when remote host connection is established. 59 // Only reset application state when remote host connection is established.
51 if (connection_helper_->ConnectionIsReadyForTest()) { 60 if (connection_helper_->ConnectionIsReadyForTest()) {
52 ResetApplicationState(); 61 ResetApplicationState();
53 } 62 }
54 63
64 test_chromoting_client_->RemoveRemoteConnectionObserver(this);
55 connection_helper_.reset(); 65 connection_helper_.reset();
56 } 66 }
57 67
58 WaitForImagePatternMatchCallback 68 WaitForImagePatternMatchCallback
59 AppRemotingLatencyTestFixture::SetExpectedImagePattern( 69 AppRemotingLatencyTestFixture::SetExpectedImagePattern(
60 const webrtc::DesktopRect& expected_rect, 70 const webrtc::DesktopRect& expected_rect,
61 uint32_t expected_color) { 71 uint32_t expected_color) {
62 DCHECK(thread_checker_.CalledOnValidThread()); 72 DCHECK(thread_checker_.CalledOnValidThread());
63 73
64 scoped_ptr<base::RunLoop> run_loop(new base::RunLoop()); 74 scoped_ptr<base::RunLoop> run_loop(new base::RunLoop());
(...skipping 19 matching lines...) Expand all
84 run_loop->Run(); 94 run_loop->Run();
85 95
86 // Image pattern is matched if we stopped because of the reply not the timer. 96 // Image pattern is matched if we stopped because of the reply not the timer.
87 bool image_pattern_is_matched = (timer_->IsRunning()); 97 bool image_pattern_is_matched = (timer_->IsRunning());
88 timer_->Stop(); 98 timer_->Stop();
89 run_loop.reset(); 99 run_loop.reset();
90 100
91 return image_pattern_is_matched; 101 return image_pattern_is_matched;
92 } 102 }
93 103
104 void AppRemotingLatencyTestFixture::HostMessageReceived(
105 const protocol::ExtensionMessage& message) {
106 DCHECK(thread_checker_.CalledOnValidThread());
107
108 if (!host_message_received_callback_.is_null()) {
109 host_message_received_callback_.Run(message);
110 }
111 }
112
94 void AppRemotingLatencyTestFixture::PressKey(uint32_t usb_keycode, 113 void AppRemotingLatencyTestFixture::PressKey(uint32_t usb_keycode,
95 bool pressed) { 114 bool pressed) {
96 remoting::protocol::KeyEvent event; 115 remoting::protocol::KeyEvent event;
97 event.set_usb_keycode(usb_keycode); 116 event.set_usb_keycode(usb_keycode);
98 event.set_pressed(pressed); 117 event.set_pressed(pressed);
99 connection_helper_->input_stub()->InjectKeyEvent(event); 118 connection_helper_->input_stub()->InjectKeyEvent(event);
100 } 119 }
101 120
102 void AppRemotingLatencyTestFixture::PressAndReleaseKey(uint32_t usb_keycode) { 121 void AppRemotingLatencyTestFixture::PressAndReleaseKey(uint32_t usb_keycode) {
103 PressKey(usb_keycode, true); 122 PressKey(usb_keycode, true);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 164
146 run_loop_.reset(new base::RunLoop()); 165 run_loop_.reset(new base::RunLoop());
147 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 166 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
148 FROM_HERE, run_loop_->QuitClosure(), base::TimeDelta::FromSeconds(2)); 167 FROM_HERE, run_loop_->QuitClosure(), base::TimeDelta::FromSeconds(2));
149 run_loop_->Run(); 168 run_loop_->Run();
150 run_loop_.reset(); 169 run_loop_.reset();
151 } 170 }
152 171
153 } // namespace test 172 } // namespace test
154 } // namespace remoting 173 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698