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

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

Issue 10920019: [Chromoting] Refactoring DesktopEnvironment and moving screen/audio recorders to ClientSession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/base/base_mock_objects.h" 9 #include "remoting/base/base_mock_objects.h"
10 #include "remoting/host/host_mock_objects.h" 10 #include "remoting/host/host_mock_objects.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 75
76 virtual void SetUp() OVERRIDE { 76 virtual void SetUp() OVERRIDE {
77 // VideoFrameCapturer and Encoder are owned by ScreenRecorder. 77 // VideoFrameCapturer and Encoder are owned by ScreenRecorder.
78 encoder_ = new MockEncoder(); 78 encoder_ = new MockEncoder();
79 79
80 session_ = new MockSession(); 80 session_ = new MockSession();
81 EXPECT_CALL(*session_, SetEventHandler(_)); 81 EXPECT_CALL(*session_, SetEventHandler(_));
82 EXPECT_CALL(*session_, Close()) 82 EXPECT_CALL(*session_, Close())
83 .Times(AnyNumber()); 83 .Times(AnyNumber());
84 connection_.reset(new MockConnectionToClient( 84 connection_.reset(new MockConnectionToClient(session_, &host_stub_));
85 session_, &host_stub_, &event_executor_));
86 connection_->SetEventHandler(&handler_); 85 connection_->SetEventHandler(&handler_);
87 86
88 record_ = new ScreenRecorder( 87 record_ = new ScreenRecorder(
89 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(), 88 message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
90 message_loop_.message_loop_proxy(), &capturer_, encoder_); 89 message_loop_.message_loop_proxy(), &capturer_, encoder_);
91 } 90 }
92 91
93 virtual void TearDown() OVERRIDE { 92 virtual void TearDown() OVERRIDE {
94 connection_.reset(); 93 connection_.reset();
95 // Run message loop before destroying because protocol::Session is 94 // Run message loop before destroying because protocol::Session is
96 // destroyed asynchronously. 95 // destroyed asynchronously.
97 message_loop_.RunAllPending(); 96 message_loop_.RunAllPending();
98 } 97 }
99 98
100 protected: 99 protected:
101 MessageLoop message_loop_; 100 MessageLoop message_loop_;
102 scoped_refptr<ScreenRecorder> record_; 101 scoped_refptr<ScreenRecorder> record_;
103 102
104 MockConnectionToClientEventHandler handler_; 103 MockConnectionToClientEventHandler handler_;
105 MockHostStub host_stub_; 104 MockHostStub host_stub_;
106 MockEventExecutor event_executor_;
107 MockSession* session_; // Owned by |connection_|. 105 MockSession* session_; // Owned by |connection_|.
108 scoped_ptr<MockConnectionToClient> connection_; 106 scoped_ptr<MockConnectionToClient> connection_;
109 107
110 // The following mock objects are owned by ScreenRecorder. 108 // The following mock objects are owned by ScreenRecorder.
111 MockVideoFrameCapturer capturer_; 109 MockVideoFrameCapturer capturer_;
112 MockEncoder* encoder_; 110 MockEncoder* encoder_;
113 111
114 private: 112 private:
115 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest); 113 DISALLOW_COPY_AND_ASSIGN(ScreenRecorderTest);
116 }; 114 };
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 message_loop_.Run(); 172 message_loop_.Run();
175 } 173 }
176 174
177 TEST_F(ScreenRecorderTest, StopWithoutStart) { 175 TEST_F(ScreenRecorderTest, StopWithoutStart) {
178 EXPECT_CALL(capturer_, Stop()); 176 EXPECT_CALL(capturer_, Stop());
179 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_)); 177 record_->Stop(base::Bind(&QuitMessageLoop, &message_loop_));
180 message_loop_.Run(); 178 message_loop_.Run();
181 } 179 }
182 180
183 } // namespace remoting 181 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698