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

Side by Side Diff: remoting/client/ios/bridge/frame_consumer_bridge_unittest.cc

Issue 2829853003: Remove crufty bridge code from old CRD iOS app. (Closed)
Patch Set: Fix remoting/display proto import issue. Created 3 years, 8 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/client/ios/bridge/frame_consumer_bridge.h"
6
7 #include <gtest/gtest.h>
8 #include <memory>
9 #include <queue>
10
11 #include "base/bind.h"
12 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
13 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
14
15 namespace {
16 const webrtc::DesktopSize kFrameSize(100, 100);
17 const webrtc::DesktopVector kDpi(100, 100);
18
19 const webrtc::DesktopRect FrameRect() {
20 return webrtc::DesktopRect::MakeSize(kFrameSize);
21 }
22
23 webrtc::DesktopRegion FrameRegion() {
24 return webrtc::DesktopRegion(FrameRect());
25 }
26
27 void FrameDelivery(webrtc::DesktopFrame* buffer,
28 const webrtc::DesktopRegion& region) {
29 ASSERT_TRUE(buffer->size().equals(kFrameSize));
30 ASSERT_TRUE(region.Equals(FrameRegion()));
31 };
32
33 } // namespace
34
35 namespace remoting {
36
37 class FrameProducerTester : public FrameProducer {
38 public:
39 virtual ~FrameProducerTester(){};
40
41 void DrawBuffer(webrtc::DesktopFrame* buffer) override {
42 frames.push(buffer);
43 };
44
45 void InvalidateRegion(const webrtc::DesktopRegion& region) override {
46 NOTIMPLEMENTED();
47 };
48
49 void RequestReturnBuffers(const base::Closure& done) override {
50 // Don't have to actually return the buffers. This function is really
51 // saying don't use the references anymore, they are now invalid.
52 while (!frames.empty()) {
53 frames.pop();
54 }
55 done.Run();
56 };
57
58 void SetOutputSizeAndClip(const webrtc::DesktopSize& view_size,
59 const webrtc::DesktopRect& clip_area) override {
60 viewSize = view_size;
61 clipArea = clip_area;
62 };
63
64 std::queue<webrtc::DesktopFrame*> frames;
65 webrtc::DesktopSize viewSize;
66 webrtc::DesktopRect clipArea;
67 };
68
69 class FrameConsumerBridgeTest : public ::testing::Test {
70 protected:
71 void SetUp() override {
72 frameProducer_.reset(new FrameProducerTester());
73 frameConsumer_.reset(new FrameConsumerBridge(base::Bind(&FrameDelivery)));
74 frameConsumer_->Initialize(frameProducer_.get());
75 }
76 void TearDown() override {}
77
78 std::unique_ptr<FrameProducerTester> frameProducer_;
79 std::unique_ptr<FrameConsumerBridge> frameConsumer_;
80 };
81
82 TEST(FrameConsumerBridgeTest_NotInitialized, CreateAndRelease) {
83 std::unique_ptr<FrameConsumerBridge> frameConsumer_(
84 new FrameConsumerBridge(base::Bind(&FrameDelivery)));
85 ASSERT_TRUE(frameConsumer_.get() != NULL);
86 frameConsumer_.reset();
87 ASSERT_TRUE(frameConsumer_.get() == NULL);
88 }
89
90 // TODO(nicholss): FrameConsumer has changed since last integration.
91 // Need to update the tests.
92 // TEST_F(FrameConsumerBridgeTest, ApplyBuffer) {
93 // webrtc::DesktopFrame* frame = NULL;
94 // ASSERT_EQ(0, frameProducer_->frames.size());
95 // frameConsumer_->SetSourceSize(kFrameSize, kDpi);
96 // ASSERT_EQ(1, frameProducer_->frames.size());
97 //
98 // // Return the frame, and ensure we get it back
99 // frame = frameProducer_->frames.front();
100 // frameProducer_->frames.pop();
101 // ASSERT_EQ(0, frameProducer_->frames.size());
102 // frameConsumer_->ApplyBuffer(
103 // kFrameSize, FrameRect(), frame, FrameRegion(), FrameRegion());
104 // ASSERT_EQ(1, frameProducer_->frames.size());
105 // ASSERT_TRUE(frame == frameProducer_->frames.front());
106 // ASSERT_TRUE(frame->data() == frameProducer_->frames.front()->data());
107 //
108 // // Change the SourceSize, we should get a new frame, but when the old frame
109 // is
110 // // submitted we will not get it back.
111 // frameConsumer_->SetSourceSize(webrtc::DesktopSize(1, 1), kDpi);
112 // ASSERT_EQ(2, frameProducer_->frames.size());
113 // frame = frameProducer_->frames.front();
114 // frameProducer_->frames.pop();
115 // ASSERT_EQ(1, frameProducer_->frames.size());
116 // frameConsumer_->ApplyBuffer(
117 // kFrameSize, FrameRect(), frame, FrameRegion(), FrameRegion());
118 // ASSERT_EQ(1, frameProducer_->frames.size());
119 // }
120 //
121 // TEST_F(FrameConsumerBridgeTest, SetSourceSize) {
122 // frameConsumer_->SetSourceSize(webrtc::DesktopSize(0, 0),
123 // webrtc::DesktopVector(0, 0));
124 // ASSERT_TRUE(frameProducer_->viewSize.equals(webrtc::DesktopSize(0, 0)));
125 // ASSERT_TRUE(frameProducer_->clipArea.equals(
126 // webrtc::DesktopRect::MakeLTRB(0, 0, 0, 0)));
127 // ASSERT_EQ(1, frameProducer_->frames.size());
128 // ASSERT_TRUE(
129 // frameProducer_->frames.front()->size().equals(webrtc::DesktopSize(0,
130 // 0)));
131 //
132 // frameConsumer_->SetSourceSize(kFrameSize, kDpi);
133 // ASSERT_TRUE(frameProducer_->viewSize.equals(kFrameSize));
134 // ASSERT_TRUE(frameProducer_->clipArea.equals(FrameRect()));
135 // ASSERT_EQ(2, frameProducer_->frames.size());
136 // frameProducer_->frames.pop();
137 // ASSERT_TRUE(frameProducer_->frames.front()->size().equals(kFrameSize));
138 // }
139
140 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/ios/bridge/frame_consumer_bridge.cc ('k') | remoting/client/ios/bridge/host_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698