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

Side by Side Diff: remoting/codec/codec_test.cc

Issue 16383002: Roll webrtc 4143:4179 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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
« no previous file with comments | « media/video/capture/screen/differ_unittest.cc ('k') | no next file » | 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) 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 <deque> 5 #include <deque>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "media/base/video_frame.h" 11 #include "media/base/video_frame.h"
12 #include "remoting/codec/codec_test.h" 12 #include "remoting/codec/codec_test.h"
13 #include "remoting/codec/video_decoder.h" 13 #include "remoting/codec/video_decoder.h"
14 #include "remoting/codec/video_encoder.h" 14 #include "remoting/codec/video_encoder.h"
15 #include "remoting/base/util.h" 15 #include "remoting/base/util.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 17 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
18 18
19 using webrtc::DesktopRect; 19 using webrtc::DesktopRect;
20 using webrtc::DesktopRegion;
20 using webrtc::DesktopSize; 21 using webrtc::DesktopSize;
21 22
22 namespace { 23 namespace {
23 24
24 const int kBytesPerPixel = 4; 25 const int kBytesPerPixel = 4;
25 26
26 // Some sample rects for testing. 27 // Some sample rects for testing.
27 std::vector<std::vector<DesktopRect> > MakeTestRectLists(DesktopSize size) { 28 std::vector<std::vector<DesktopRect> > MakeTestRectLists(DesktopSize size) {
28 std::vector<std::vector<DesktopRect> > rect_lists; 29 std::vector<std::vector<DesktopRect> > rect_lists;
29 std::vector<DesktopRect> rects; 30 std::vector<DesktopRect> rects;
(...skipping 19 matching lines...) Expand all
49 50
50 namespace remoting { 51 namespace remoting {
51 52
52 // A class to test the message output of the encoder. 53 // A class to test the message output of the encoder.
53 class VideoEncoderMessageTester { 54 class VideoEncoderMessageTester {
54 public: 55 public:
55 VideoEncoderMessageTester() 56 VideoEncoderMessageTester()
56 : begin_rect_(0), 57 : begin_rect_(0),
57 rect_data_(0), 58 rect_data_(0),
58 end_rect_(0), 59 end_rect_(0),
59 added_rects_(0),
60 state_(kWaitingForBeginRect), 60 state_(kWaitingForBeginRect),
61 strict_(false) { 61 strict_(false) {
62 } 62 }
63 63
64 ~VideoEncoderMessageTester() { 64 ~VideoEncoderMessageTester() {
65 EXPECT_EQ(begin_rect_, end_rect_); 65 EXPECT_EQ(begin_rect_, end_rect_);
66 EXPECT_GT(begin_rect_, 0); 66 EXPECT_GT(begin_rect_, 0);
67 EXPECT_EQ(kWaitingForBeginRect, state_); 67 EXPECT_EQ(kWaitingForBeginRect, state_);
68 if (strict_) { 68 if (strict_) {
69 EXPECT_EQ(added_rects_, begin_rect_); 69 EXPECT_TRUE(region_.Equals(received_region_));
70 } 70 }
71 } 71 }
72 72
73 // Test that we received the correct packet. 73 // Test that we received the correct packet.
74 void ReceivedPacket(VideoPacket* packet) { 74 void ReceivedPacket(VideoPacket* packet) {
75 if (state_ == kWaitingForBeginRect) { 75 if (state_ == kWaitingForBeginRect) {
76 EXPECT_TRUE((packet->flags() & VideoPacket::FIRST_PACKET) != 0); 76 EXPECT_TRUE((packet->flags() & VideoPacket::FIRST_PACKET) != 0);
77 state_ = kWaitingForRectData; 77 state_ = kWaitingForRectData;
78 ++begin_rect_; 78 ++begin_rect_;
79 79
80 if (strict_) { 80 if (strict_) {
81 DesktopRect rect = rects_.front(); 81 received_region_.AddRect(webrtc::DesktopRect::MakeXYWH(
82 rects_.pop_front(); 82 packet->format().x(), packet->format().y(),
83 EXPECT_EQ(rect.left(), packet->format().x()); 83 packet->format().width(), packet->format().height()));
84 EXPECT_EQ(rect.top(), packet->format().y());
85 EXPECT_EQ(rect.width(), packet->format().width());
86 EXPECT_EQ(rect.height(), packet->format().height());
87 } 84 }
88 } else { 85 } else {
89 EXPECT_FALSE((packet->flags() & VideoPacket::FIRST_PACKET) != 0); 86 EXPECT_FALSE((packet->flags() & VideoPacket::FIRST_PACKET) != 0);
90 } 87 }
91 88
92 if (state_ == kWaitingForRectData) { 89 if (state_ == kWaitingForRectData) {
93 if (packet->has_data()) { 90 if (packet->has_data()) {
94 ++rect_data_; 91 ++rect_data_;
95 } 92 }
96 93
(...skipping 10 matching lines...) Expand all
107 EXPECT_TRUE((packet->flags() & VideoPacket::LAST_PACKET) != 0); 104 EXPECT_TRUE((packet->flags() & VideoPacket::LAST_PACKET) != 0);
108 } 105 }
109 } 106 }
110 } 107 }
111 108
112 void set_strict(bool strict) { 109 void set_strict(bool strict) {
113 strict_ = strict; 110 strict_ = strict;
114 } 111 }
115 112
116 void AddRects(const DesktopRect* rects, int count) { 113 void AddRects(const DesktopRect* rects, int count) {
117 rects_.insert(rects_.begin() + rects_.size(), rects, rects + count); 114 region_.AddRects(rects, count);
118 added_rects_ += count;
119 } 115 }
120 116
121 private: 117 private:
122 enum State { 118 enum State {
123 kWaitingForBeginRect, 119 kWaitingForBeginRect,
124 kWaitingForRectData, 120 kWaitingForRectData,
125 }; 121 };
126 122
127 int begin_rect_; 123 int begin_rect_;
128 int rect_data_; 124 int rect_data_;
129 int end_rect_; 125 int end_rect_;
130 int added_rects_;
131 State state_; 126 State state_;
132 bool strict_; 127 bool strict_;
133 128
134 std::deque<DesktopRect> rects_; 129 DesktopRegion region_;
130 DesktopRegion received_region_;
135 131
136 DISALLOW_COPY_AND_ASSIGN(VideoEncoderMessageTester); 132 DISALLOW_COPY_AND_ASSIGN(VideoEncoderMessageTester);
137 }; 133 };
138 134
139 class VideoDecoderTester { 135 class VideoDecoderTester {
140 public: 136 public:
141 VideoDecoderTester(VideoDecoder* decoder, 137 VideoDecoderTester(VideoDecoder* decoder,
142 const DesktopSize& screen_size, 138 const DesktopSize& screen_size,
143 const DesktopSize& view_size) 139 const DesktopSize& view_size)
144 : screen_size_(screen_size), 140 : screen_size_(screen_size),
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 decoder_tester.ResetRenderedData(); 486 decoder_tester.ResetRenderedData();
491 decoder->Invalidate( 487 decoder->Invalidate(
492 SkISize::Make(view_size.width(), view_size.height()), 488 SkISize::Make(view_size.width(), view_size.height()),
493 SkRegion(SkIRect::MakeWH(view_size.width(), view_size.height()))); 489 SkRegion(SkIRect::MakeWH(view_size.width(), view_size.height())));
494 decoder_tester.RenderFrame(); 490 decoder_tester.RenderFrame();
495 decoder_tester.VerifyResultsApprox(expected_result->data(), 491 decoder_tester.VerifyResultsApprox(expected_result->data(),
496 max_error_limit, mean_error_limit); 492 max_error_limit, mean_error_limit);
497 } 493 }
498 494
499 } // namespace remoting 495 } // namespace remoting
OLDNEW
« no previous file with comments | « media/video/capture/screen/differ_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698