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

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

Issue 8476018: Move ConnectionToClient::EventHandler from ChromotingHost to ClientSession (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/screen_recorder.h" 5 #include "remoting/host/screen_recorder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/task.h" 9 #include "base/task.h"
10 #include "remoting/base/base_mock_objects.h" 10 #include "remoting/base/base_mock_objects.h"
11 #include "remoting/host/host_mock_objects.h" 11 #include "remoting/host/host_mock_objects.h"
12 #include "remoting/proto/video.pb.h" 12 #include "remoting/proto/video.pb.h"
13 #include "remoting/protocol/protocol_mock_objects.h" 13 #include "remoting/protocol/protocol_mock_objects.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using ::remoting::protocol::MockConnectionToClient; 17 using ::remoting::protocol::MockConnectionToClient;
18 using ::remoting::protocol::MockConnectionToClientEventHandler; 18 using ::remoting::protocol::MockConnectionToClientEventHandler;
19 using ::remoting::protocol::MockHostStub; 19 using ::remoting::protocol::MockHostStub;
20 using ::remoting::protocol::MockSession;
20 using ::remoting::protocol::MockVideoStub; 21 using ::remoting::protocol::MockVideoStub;
21 22
22 using ::testing::_; 23 using ::testing::_;
23 using ::testing::AtLeast; 24 using ::testing::AtLeast;
24 using ::testing::DeleteArg; 25 using ::testing::DeleteArg;
25 using ::testing::DoAll; 26 using ::testing::DoAll;
26 using ::testing::InSequence; 27 using ::testing::InSequence;
27 using ::testing::InvokeWithoutArgs; 28 using ::testing::InvokeWithoutArgs;
28 using ::testing::NotNull; 29 using ::testing::NotNull;
29 using ::testing::Return; 30 using ::testing::Return;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 71
71 class ScreenRecorderTest : public testing::Test { 72 class ScreenRecorderTest : public testing::Test {
72 public: 73 public:
73 ScreenRecorderTest() { 74 ScreenRecorderTest() {
74 } 75 }
75 76
76 virtual void SetUp() { 77 virtual void SetUp() {
77 // Capturer and Encoder are owned by ScreenRecorder. 78 // Capturer and Encoder are owned by ScreenRecorder.
78 encoder_ = new MockEncoder(); 79 encoder_ = new MockEncoder();
79 80
81 session_ = new MockSession();
82 EXPECT_CALL(*session_, SetStateChangeCallback(_));
80 connection_ = new MockConnectionToClient( 83 connection_ = new MockConnectionToClient(
81 &handler_, &host_stub_, &event_executor_); 84 session_, &host_stub_, &event_executor_);
85 connection_->SetEventHandler(&handler_);
82 86
83 record_ = new ScreenRecorder( 87 record_ = new ScreenRecorder(
84 &message_loop_, &message_loop_, 88 &message_loop_, &message_loop_,
85 base::MessageLoopProxy::current(), 89 base::MessageLoopProxy::current(),
86 &capturer_, encoder_); 90 &capturer_, encoder_);
87 } 91 }
88 92
89 protected: 93 protected:
90 scoped_refptr<ScreenRecorder> record_; 94 scoped_refptr<ScreenRecorder> record_;
91 95
92 MockConnectionToClientEventHandler handler_; 96 MockConnectionToClientEventHandler handler_;
93 MockHostStub host_stub_; 97 MockHostStub host_stub_;
94 MockEventExecutor event_executor_; 98 MockEventExecutor event_executor_;
99 MockSession* session_; // Owned by |connection_|.
95 scoped_refptr<MockConnectionToClient> connection_; 100 scoped_refptr<MockConnectionToClient> connection_;
96 101
97 // The following mock objects are owned by ScreenRecorder. 102 // The following mock objects are owned by ScreenRecorder.
98 MockCapturer capturer_; 103 MockCapturer capturer_;
99 MockEncoder* encoder_; 104 MockEncoder* encoder_;
100 MessageLoop message_loop_; 105 MessageLoop message_loop_;
101 private: 106 private:
102 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); 107 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest);
103 }; 108 };
104 109
105 // This test mocks capturer, encoder and network layer to operate one recording 110 // This test mocks capturer, encoder and network layer to operate one recording
106 // cycle. 111 // cycle.
107 TEST_F(ScreenRecorderTest, OneRecordCycle) { 112 TEST_F(ScreenRecorderTest, OneRecordCycle) {
Wez 2011/11/09 23:34:50 Did you mean to remove this?
Sergey Ulanov 2011/11/10 00:55:57 Alpha removed it (http://codereview.chromium.org/8
108 SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10)); 113 SkRegion update_region(SkIRect::MakeXYWH(0, 0, 10, 10));
109 DataPlanes planes; 114 DataPlanes planes;
110 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { 115 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) {
111 planes.data[i] = reinterpret_cast<uint8*>(i); 116 planes.data[i] = reinterpret_cast<uint8*>(i);
112 planes.strides[i] = kWidth * 4; 117 planes.strides[i] = kWidth * 4;
113 } 118 }
114 SkISize size(SkISize::Make(kWidth, kHeight)); 119 SkISize size(SkISize::Make(kWidth, kHeight));
115 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat)); 120 scoped_refptr<CaptureData> data(new CaptureData(planes, size, kFormat));
116 EXPECT_CALL(capturer_, InvalidateFullScreen()); 121 EXPECT_CALL(capturer_, InvalidateFullScreen());
117 122
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 record_->Start(); 201 record_->Start();
197 message_loop_.Run(); 202 message_loop_.Run();
198 } 203 }
199 204
200 TEST_F(ScreenRecorderTest, StopWithoutStart) { 205 TEST_F(ScreenRecorderTest, StopWithoutStart) {
201 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); 206 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_));
202 message_loop_.Run(); 207 message_loop_.Run();
203 } 208 }
204 209
205 } // namespace remoting 210 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698