OLD | NEW |
---|---|
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/session_manager.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 public: | 26 public: |
27 SessionManagerTest() { | 27 SessionManagerTest() { |
28 } | 28 } |
29 | 29 |
30 protected: | 30 protected: |
31 void Init() { | 31 void Init() { |
32 capturer_ = new MockCapturer(); | 32 capturer_ = new MockCapturer(); |
33 encoder_ = new MockEncoder(); | 33 encoder_ = new MockEncoder(); |
34 client_ = new MockClientConnection(); | 34 client_ = new MockClientConnection(); |
35 record_ = new SessionManager(&message_loop_, | 35 record_ = new SessionManager(&message_loop_, |
36 &message_loop_, | 36 &message_loop_, |
37 &message_loop_, | 37 &message_loop_, |
38 capturer_, | 38 capturer_, |
39 encoder_); | 39 encoder_); |
40 } | 40 } |
41 | 41 |
42 scoped_refptr<SessionManager> record_; | 42 scoped_refptr<SessionManager> record_; |
43 scoped_refptr<MockClientConnection> client_; | 43 scoped_refptr<MockClientConnection> client_; |
44 MockCapturer* capturer_; | 44 MockCapturer* capturer_; |
45 MockEncoder* encoder_; | 45 MockEncoder* encoder_; |
46 MessageLoop message_loop_; | 46 MessageLoop message_loop_; |
47 private: | 47 private: |
48 DISALLOW_COPY_AND_ASSIGN(SessionManagerTest); | 48 DISALLOW_COPY_AND_ASSIGN(SessionManagerTest); |
49 }; | 49 }; |
(...skipping 11 matching lines...) Expand all Loading... | |
61 dirty_rects.swap(temp_rects); | 61 dirty_rects.swap(temp_rects); |
62 arg0->Run(data); | 62 arg0->Run(data); |
63 delete arg0; | 63 delete arg0; |
64 } | 64 } |
65 | 65 |
66 ACTION_P(FinishEncode, msg) { | 66 ACTION_P(FinishEncode, msg) { |
67 Encoder::EncodingState state = (Encoder::EncodingStarting | | 67 Encoder::EncodingState state = (Encoder::EncodingStarting | |
68 Encoder::EncodingInProgress | | 68 Encoder::EncodingInProgress | |
69 Encoder::EncodingEnded); | 69 Encoder::EncodingEnded); |
70 arg2->Run(msg, state); | 70 arg2->Run(msg, state); |
71 } | 71 delete arg2; |
awong
2010/08/26 20:39:06
Stupid non-self-deleting callbacks.
| |
72 | |
73 ACTION_P(AssignCaptureData, data) { | |
74 arg0[0] = data[0]; | |
75 arg0[1] = data[1]; | |
76 arg0[2] = data[2]; | |
77 } | |
78 | |
79 ACTION_P(AssignDirtyRect, rects) { | |
80 *arg0 = *rects; | |
81 } | 72 } |
82 | 73 |
83 TEST_F(SessionManagerTest, OneRecordCycle) { | 74 TEST_F(SessionManagerTest, OneRecordCycle) { |
84 Init(); | 75 Init(); |
85 | 76 |
86 InvalidRects update_rects; | 77 InvalidRects update_rects; |
87 update_rects.insert(gfx::Rect(0, 0, 10, 10)); | 78 update_rects.insert(gfx::Rect(0, 0, 10, 10)); |
88 DataPlanes planes; | 79 DataPlanes planes; |
89 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { | 80 for (int i = 0; i < DataPlanes::kPlaneCount; ++i) { |
90 planes.data[i] = reinterpret_cast<uint8*>(i); | 81 planes.data[i] = reinterpret_cast<uint8*>(i); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 | 114 |
124 // Make sure all tasks are completed. | 115 // Make sure all tasks are completed. |
125 message_loop_.RunAllPending(); | 116 message_loop_.RunAllPending(); |
126 } | 117 } |
127 | 118 |
128 // TODO(hclam): Add test for double buffering. | 119 // TODO(hclam): Add test for double buffering. |
129 // TODO(hclam): Add test for multiple captures. | 120 // TODO(hclam): Add test for multiple captures. |
130 // TODO(hclam): Add test for interruption. | 121 // TODO(hclam): Add test for interruption. |
131 | 122 |
132 } // namespace remoting | 123 } // namespace remoting |
OLD | NEW |