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

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

Issue 5118002: Rename SessionManager to ScreenRecorder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 #include "base/task.h" 6 #include "base/task.h"
7 #include "remoting/base/mock_objects.h" 7 #include "remoting/base/mock_objects.h"
8 #include "remoting/host/mock_objects.h" 8 #include "remoting/host/mock_objects.h"
9 #include "remoting/host/session_manager.h" 9 #include "remoting/host/screen_recorder.h"
10 #include "remoting/proto/video.pb.h" 10 #include "remoting/proto/video.pb.h"
11 #include "remoting/protocol/mock_objects.h" 11 #include "remoting/protocol/mock_objects.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 using ::remoting::protocol::MockConnectionToClient; 15 using ::remoting::protocol::MockConnectionToClient;
16 16
17 using ::testing::_; 17 using ::testing::_;
18 using ::testing::AtLeast; 18 using ::testing::AtLeast;
19 using ::testing::NotNull; 19 using ::testing::NotNull;
20 using ::testing::Return; 20 using ::testing::Return;
21 21
22 namespace remoting { 22 namespace remoting {
23 23
24 static const int kWidth = 640; 24 static const int kWidth = 640;
25 static const int kHeight = 480; 25 static const int kHeight = 480;
26 static const media::VideoFrame::Format kFormat = media::VideoFrame::RGB32; 26 static const media::VideoFrame::Format kFormat = media::VideoFrame::RGB32;
27 static const VideoPacketFormat::Encoding kEncoding = 27 static const VideoPacketFormat::Encoding kEncoding =
28 VideoPacketFormat::ENCODING_VERBATIM; 28 VideoPacketFormat::ENCODING_VERBATIM;
29 29
30 class SessionManagerTest : public testing::Test { 30 class ScreenRecorderTest : public testing::Test {
31 public: 31 public:
32 SessionManagerTest() { 32 ScreenRecorderTest() {
33 } 33 }
34 34
35 protected: 35 protected:
36 void Init() { 36 void Init() {
37 capturer_ = new MockCapturer(); 37 capturer_ = new MockCapturer();
38 encoder_ = new MockEncoder(); 38 encoder_ = new MockEncoder();
39 connection_ = new MockConnectionToClient(); 39 connection_ = new MockConnectionToClient();
40 record_ = new SessionManager( 40 record_ = new ScreenRecorder(
41 &message_loop_, &message_loop_, &message_loop_, 41 &message_loop_, &message_loop_, &message_loop_,
42 capturer_, encoder_); 42 capturer_, encoder_);
43 } 43 }
44 44
45 scoped_refptr<SessionManager> record_; 45 scoped_refptr<ScreenRecorder> record_;
46 scoped_refptr<MockConnectionToClient> connection_; 46 scoped_refptr<MockConnectionToClient> connection_;
47 MockCapturer* capturer_; 47 MockCapturer* capturer_;
48 MockEncoder* encoder_; 48 MockEncoder* encoder_;
49 MessageLoop message_loop_; 49 MessageLoop message_loop_;
50 private: 50 private:
51 DISALLOW_COPY_AND_ASSIGN(SessionManagerTest); 51 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest);
52 }; 52 };
53 53
54 TEST_F(SessionManagerTest, Init) { 54 TEST_F(ScreenRecorderTest, Init) {
55 Init(); 55 Init();
dmac 2010/11/17 16:37:54 why do we use Init() instead of SetUp?
56 } 56 }
57 57
58 ACTION_P2(RunCallback, rects, data) { 58 ACTION_P2(RunCallback, rects, data) {
59 InvalidRects& dirty_rects = data->mutable_dirty_rects(); 59 InvalidRects& dirty_rects = data->mutable_dirty_rects();
60 InvalidRects temp_rects; 60 InvalidRects temp_rects;
61 std::set_union(dirty_rects.begin(), dirty_rects.end(), 61 std::set_union(dirty_rects.begin(), dirty_rects.end(),
62 rects.begin(), rects.end(), 62 rects.begin(), rects.end(),
63 std::inserter(temp_rects, temp_rects.begin())); 63 std::inserter(temp_rects, temp_rects.begin()));
64 dirty_rects.swap(temp_rects); 64 dirty_rects.swap(temp_rects);
65 arg0->Run(data); 65 arg0->Run(data);
66 delete arg0; 66 delete arg0;
67 } 67 }
68 68
69 ACTION_P(FinishEncode, msg) { 69 ACTION_P(FinishEncode, msg) {
70 arg2->Run(msg); 70 arg2->Run(msg);
71 delete arg2; 71 delete arg2;
72 } 72 }
73 73
74 // BUG 57351 74 // BUG 57351
75 TEST_F(SessionManagerTest, DISABLED_OneRecordCycle) { 75 TEST_F(ScreenRecorderTest, OneRecordCycle) {
76 Init(); 76 Init();
77 77
78 InvalidRects update_rects; 78 InvalidRects update_rects;
79 update_rects.insert(gfx::Rect(0, 0, 10, 10)); 79 update_rects.insert(gfx::Rect(0, 0, 10, 10));
80 DataPlanes planes; 80 DataPlanes planes;
81 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { 81 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) {
82 planes.data[i] = reinterpret_cast<uint8*>(i); 82 planes.data[i] = reinterpret_cast<uint8*>(i);
83 planes.strides[i] = kWidth * 4; 83 planes.strides[i] = kWidth * 4;
84 } 84 }
85 scoped_refptr<CaptureData> data(new CaptureData(planes, kWidth, 85 scoped_refptr<CaptureData> data(new CaptureData(planes, kWidth,
(...skipping 26 matching lines...) Expand all
112 112
113 // Make sure all tasks are completed. 113 // Make sure all tasks are completed.
114 message_loop_.RunAllPending(); 114 message_loop_.RunAllPending();
115 } 115 }
116 116
117 // TODO(hclam): Add test for double buffering. 117 // TODO(hclam): Add test for double buffering.
118 // TODO(hclam): Add test for multiple captures. 118 // TODO(hclam): Add test for multiple captures.
119 // TODO(hclam): Add test for interruption. 119 // TODO(hclam): Add test for interruption.
120 120
121 } // namespace remoting 121 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698