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

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: fixed 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
« no previous file with comments | « remoting/host/screen_recorder.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 virtual void SetUp() {
36 void Init() {
37 capturer_ = new MockCapturer(); 36 capturer_ = new MockCapturer();
38 encoder_ = new MockEncoder(); 37 encoder_ = new MockEncoder();
39 connection_ = new MockConnectionToClient(); 38 connection_ = new MockConnectionToClient();
40 record_ = new SessionManager( 39 record_ = new ScreenRecorder(
41 &message_loop_, &message_loop_, &message_loop_, 40 &message_loop_, &message_loop_, &message_loop_,
42 capturer_, encoder_); 41 capturer_, encoder_);
43 } 42 }
44 43
45 scoped_refptr<SessionManager> record_; 44 protected:
45 scoped_refptr<ScreenRecorder> record_;
46 scoped_refptr<MockConnectionToClient> connection_; 46 scoped_refptr<MockConnectionToClient> connection_;
47 MockCapturer* capturer_; 47 MockCapturer* capturer_;
dmac 2010/11/17 21:58:19 what's the ownership on these guys? It looks like
Alpha Left Google 2010/11/19 23:19:22 capturer_ and encoder_ are deleted by ScreenRecord
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) {
55 Init();
56 }
57
58 ACTION_P2(RunCallback, rects, data) { 54 ACTION_P2(RunCallback, rects, data) {
59 InvalidRects& dirty_rects = data->mutable_dirty_rects(); 55 InvalidRects& dirty_rects = data->mutable_dirty_rects();
60 InvalidRects temp_rects; 56 InvalidRects temp_rects;
61 std::set_union(dirty_rects.begin(), dirty_rects.end(), 57 std::set_union(dirty_rects.begin(), dirty_rects.end(),
62 rects.begin(), rects.end(), 58 rects.begin(), rects.end(),
63 std::inserter(temp_rects, temp_rects.begin())); 59 std::inserter(temp_rects, temp_rects.begin()));
64 dirty_rects.swap(temp_rects); 60 dirty_rects.swap(temp_rects);
65 arg0->Run(data); 61 arg0->Run(data);
66 delete arg0; 62 delete arg0;
67 } 63 }
68 64
69 ACTION_P(FinishEncode, msg) { 65 ACTION_P(FinishEncode, msg) {
70 arg2->Run(msg); 66 arg2->Run(msg);
71 delete arg2; 67 delete arg2;
72 } 68 }
73 69
74 // BUG 57351 70 TEST_F(ScreenRecorderTest, OneRecordCycle) {
75 TEST_F(SessionManagerTest, DISABLED_OneRecordCycle) {
76 Init();
77
78 InvalidRects update_rects; 71 InvalidRects update_rects;
79 update_rects.insert(gfx::Rect(0, 0, 10, 10)); 72 update_rects.insert(gfx::Rect(0, 0, 10, 10));
80 DataPlanes planes; 73 DataPlanes planes;
81 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { 74 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) {
82 planes.data[i] = reinterpret_cast<uint8*>(i); 75 planes.data[i] = reinterpret_cast<uint8*>(i);
83 planes.strides[i] = kWidth * 4; 76 planes.strides[i] = kWidth * 4;
84 } 77 }
85 scoped_refptr<CaptureData> data(new CaptureData(planes, kWidth, 78 scoped_refptr<CaptureData> data(new CaptureData(planes, kWidth,
86 kHeight, kFormat)); 79 kHeight, kFormat));
87 // Set the recording rate to very low to avoid capture twice. 80 // Set the recording rate to very low to avoid capture twice.
(...skipping 24 matching lines...) Expand all
112 105
113 // Make sure all tasks are completed. 106 // Make sure all tasks are completed.
114 message_loop_.RunAllPending(); 107 message_loop_.RunAllPending();
115 } 108 }
116 109
117 // TODO(hclam): Add test for double buffering. 110 // TODO(hclam): Add test for double buffering.
118 // TODO(hclam): Add test for multiple captures. 111 // TODO(hclam): Add test for multiple captures.
119 // TODO(hclam): Add test for interruption. 112 // TODO(hclam): Add test for interruption.
120 113
121 } // namespace remoting 114 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/screen_recorder.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698