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

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

Issue 468613002: Readability review. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/codec/video_encoder.h" 5 #include "remoting/codec/video_encoder.h"
6 #include "remoting/host/fake_host_extension.h" 6 #include "remoting/host/fake_host_extension.h"
7 #include "remoting/host/host_extension_session_manager.h" 7 #include "remoting/host/host_extension_session_manager.h"
8 #include "remoting/host/host_mock_objects.h" 8 #include "remoting/host/host_mock_objects.h"
9 #include "remoting/proto/control.pb.h" 9 #include "remoting/proto/control.pb.h"
10 #include "remoting/protocol/protocol_mock_objects.h" 10 #include "remoting/protocol/protocol_mock_objects.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" 12 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
13 13
14 namespace remoting { 14 namespace remoting {
15 15
16 class HostExtensionSessionManagerTest : public testing::Test { 16 class HostExtensionSessionManagerTest : public testing::Test {
17 public: 17 public:
18 HostExtensionSessionManagerTest() 18 HostExtensionSessionManagerTest()
19 : extension1_("ext1", "cap1"), 19 : extension1_("ext1", "cap1"),
20 extension2_("ext2", ""), 20 extension2_("ext2", ""),
Peter Kasting 2014/08/22 06:38:29 Nit: Prefer std::string() over ""
Wez 2014/08/25 23:23:11 Done.
21 extension3_("ext3", "cap3") { 21 extension3_("ext3", "cap3") {
22 extensions_.push_back(&extension1_); 22 extensions_.push_back(&extension1_);
23 extensions_.push_back(&extension2_); 23 extensions_.push_back(&extension2_);
24 extensions_.push_back(&extension3_); 24 extensions_.push_back(&extension3_);
25 } 25 }
26 virtual ~HostExtensionSessionManagerTest() {} 26 virtual ~HostExtensionSessionManagerTest() {}
27 27
28 protected: 28 protected:
Peter Kasting 2014/08/22 06:38:29 Nit: In general, the Google style guide prefers pr
Wez 2014/08/25 23:23:11 For a general purpose class I'd agree, but this is
Peter Kasting 2014/08/25 23:39:06 The main benefits that normally accrue involve cla
Wez 2014/08/26 19:22:25 OK, thanks for clarifying.
29 // Fake HostExtensions for testing. 29 // Fake HostExtensions for testing.
30 FakeExtension extension1_; 30 FakeExtension extension1_;
31 FakeExtension extension2_; 31 FakeExtension extension2_;
32 FakeExtension extension3_; 32 FakeExtension extension3_;
33 std::vector<HostExtension*> extensions_; 33 std::vector<HostExtension*> extensions_;
34 34
35 // Mocks of interfaces provided by ClientSession. 35 // Mocks of interfaces provided by ClientSession.
36 MockClientSessionControl client_session_control_; 36 MockClientSessionControl client_session_control_;
37 protocol::MockClientStub client_stub_; 37 protocol::MockClientStub client_stub_;
38 }; 38 };
Peter Kasting 2014/08/22 06:38:29 Nit: DISALLOW_COPY_AND_ASSIGN()
Wez 2014/08/25 23:23:11 Done.
39 39
40 // Verifies that messages are passed to be handled by the correct extension. 40 // Verifies that messages are passed to be handled by the correct extension.
Peter Kasting 2014/08/22 06:38:29 Nit: I'm not sure what this sentence means, but it
Wez 2014/08/25 23:23:11 Done.
41 TEST_F(HostExtensionSessionManagerTest, ExtensionMessages_MessageHandled) { 41 TEST_F(HostExtensionSessionManagerTest, ExtensionMessages_MessageHandled) {
42 HostExtensionSessionManager extension_manager(extensions_, 42 HostExtensionSessionManager extension_manager(extensions_,
43 &client_session_control_); 43 &client_session_control_);
44 extension_manager.OnNegotiatedCapabilities( 44 extension_manager.OnNegotiatedCapabilities(
45 &client_stub_, extension_manager.GetCapabilities()); 45 &client_stub_, extension_manager.GetCapabilities());
46 46
47 protocol::ExtensionMessage message; 47 protocol::ExtensionMessage message;
48 message.set_type("ext2"); 48 message.set_type("ext2");
49 extension_manager.OnExtensionMessage(message); 49 extension_manager.OnExtensionMessage(message);
50 50
(...skipping 18 matching lines...) Expand all
69 EXPECT_FALSE(extension2_.has_handled_message()); 69 EXPECT_FALSE(extension2_.has_handled_message());
70 EXPECT_FALSE(extension3_.has_handled_message()); 70 EXPECT_FALSE(extension3_.has_handled_message());
71 } 71 }
72 72
73 // Verifies that the correct set of capabilities are reported to the client, 73 // Verifies that the correct set of capabilities are reported to the client,
74 // based on the registered extensions. 74 // based on the registered extensions.
75 TEST_F(HostExtensionSessionManagerTest, ExtensionCapabilities_AreReported) { 75 TEST_F(HostExtensionSessionManagerTest, ExtensionCapabilities_AreReported) {
76 HostExtensionSessionManager extension_manager(extensions_, 76 HostExtensionSessionManager extension_manager(extensions_,
77 &client_session_control_); 77 &client_session_control_);
78 78
79 EXPECT_EQ(extension_manager.GetCapabilities(), "cap1 cap3"); 79 EXPECT_EQ(extension_manager.GetCapabilities(), "cap1 cap3");
Peter Kasting 2014/08/22 06:38:29 Would it be equally valid to return "cap3 cap1"?
Wez 2014/08/25 23:23:11 Good point; have updated the test to account for t
80 } 80 }
81 81
82 // Verifies that an extension is not instantiated if the client does not 82 // Verifies that an extension is not instantiated if the client does not
83 // support its required capability, and that it does not receive messages. 83 // support its required capability, and that it does not receive messages.
84 TEST_F(HostExtensionSessionManagerTest, ExtensionCapabilities_AreChecked) { 84 TEST_F(HostExtensionSessionManagerTest, ExtensionCapabilities_AreChecked) {
85 HostExtensionSessionManager extension_manager(extensions_, 85 HostExtensionSessionManager extension_manager(extensions_,
86 &client_session_control_); 86 &client_session_control_);
87 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); 87 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1");
88 88
89 protocol::ExtensionMessage message; 89 protocol::ExtensionMessage message;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 scoped_ptr<webrtc::DesktopCapturer>()); 152 scoped_ptr<webrtc::DesktopCapturer>());
153 extension_manager.OnCreateVideoEncoder(scoped_ptr<VideoEncoder>()); 153 extension_manager.OnCreateVideoEncoder(scoped_ptr<VideoEncoder>());
154 154
155 EXPECT_FALSE(extension1_.has_wrapped_video_encoder()); 155 EXPECT_FALSE(extension1_.has_wrapped_video_encoder());
156 EXPECT_FALSE(extension1_.has_wrapped_video_capturer()); 156 EXPECT_FALSE(extension1_.has_wrapped_video_capturer());
157 EXPECT_TRUE(extension2_.has_wrapped_video_encoder()); 157 EXPECT_TRUE(extension2_.has_wrapped_video_encoder());
158 EXPECT_TRUE(extension2_.has_wrapped_video_capturer()); 158 EXPECT_TRUE(extension2_.has_wrapped_video_capturer());
159 EXPECT_FALSE(extension3_.was_instantiated()); 159 EXPECT_FALSE(extension3_.was_instantiated());
160 } 160 }
161 161
162 // Verifies that if an extension reports that they modify the video pipeline 162 // Verifies that if an extension reports that they modify the video pipeline
Peter Kasting 2014/08/22 06:38:29 Nit: they modify -> it modifies
Wez 2014/08/25 23:23:11 Done.
163 // then ResetVideoPipeline() is called on the ClientSessionControl interface. 163 // then ResetVideoPipeline() is called on the ClientSessionControl interface.
164 TEST_F(HostExtensionSessionManagerTest, CallsResetVideoPipeline) { 164 TEST_F(HostExtensionSessionManagerTest, CallsResetVideoPipeline) {
165 HostExtensionSessionManager extension_manager(extensions_, 165 HostExtensionSessionManager extension_manager(extensions_,
166 &client_session_control_); 166 &client_session_control_);
167 167
168 EXPECT_CALL(client_session_control_, ResetVideoPipeline()); 168 EXPECT_CALL(client_session_control_, ResetVideoPipeline());
169 169
170 // Set up only the first extension to request to modify the video pipeline. 170 // Set up only the first extension to request to modify the video pipeline.
171 extension1_.set_steal_video_capturer(true); 171 extension1_.set_steal_video_capturer(true);
172 172
173 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1"); 173 extension_manager.OnNegotiatedCapabilities(&client_stub_, "cap1");
174 } 174 }
175 175
176 176
177 } // namespace remoting 177 } // namespace remoting
178
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698