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

Unified Diff: remoting/host/encoder_vp8_unittest.cc

Issue 2690003: Copy the (early prototype of) remoting in Chrome into the public tree.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/encoder_vp8.cc ('k') | remoting/host/event_executor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/encoder_vp8_unittest.cc
===================================================================
--- remoting/host/encoder_vp8_unittest.cc (revision 0)
+++ remoting/host/encoder_vp8_unittest.cc (revision 0)
@@ -0,0 +1,69 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "media/base/data_buffer.h"
+#include "remoting/base/pixel_format.h"
+#include "remoting/host/encoder_vp8.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace remoting {
+
+static const int kWidth = 1024;
+static const int kHeight = 768;
+static const PixelFormat kPixelFormat = kPixelFormat_YV12;
+
+static void GenerateData(uint8* data, int size) {
+ for (int i = 0; i < size; ++i) {
+ data[i] = i;
+ }
+}
+
+class EncodeDoneHandler
+ : public base::RefCountedThreadSafe<EncodeDoneHandler> {
+ public:
+ MOCK_METHOD0(EncodeDone, void());
+};
+
+TEST(EncoderVp8Test, SimpleEncode) {
+ EncoderVp8 encoder;
+ encoder.SetSize(kWidth, kHeight);
+ encoder.SetPixelFormat(kPixelFormat);
+
+ DirtyRects rects;
+ rects.push_back(gfx::Rect(kWidth, kHeight));
+
+ // Prepare memory for encoding.
+ int strides[3];
+ strides[0] = kWidth;
+ strides[1] = strides[2] = kWidth / 2;
+
+ uint8* planes[3];
+ planes[0] = new uint8[kWidth * kHeight];
+ planes[1] = new uint8[kWidth * kHeight / 4];
+ planes[2] = new uint8[kWidth * kHeight / 4];
+ GenerateData(planes[0], kWidth * kHeight);
+ GenerateData(planes[1], kWidth * kHeight / 4);
+ GenerateData(planes[2], kWidth * kHeight / 4);
+
+ scoped_refptr<EncodeDoneHandler> handler = new EncodeDoneHandler();
+ chromotocol_pb::UpdateStreamPacketHeader* header
+ = new chromotocol_pb::UpdateStreamPacketHeader();
+ scoped_refptr<media::DataBuffer> encoded_data;
+ bool encode_done = false;
+ EXPECT_CALL(*handler, EncodeDone());
+ encoder.Encode(rects, const_cast<const uint8**>(planes),
+ strides, true, header, &encoded_data, &encode_done,
+ NewRunnableMethod(handler.get(),
+ &EncodeDoneHandler::EncodeDone));
+
+ EXPECT_TRUE(encode_done);
+ ASSERT_TRUE(encoded_data.get());
+ EXPECT_NE(0u, encoded_data->GetBufferSize());
+
+ delete [] planes[0];
+ delete [] planes[1];
+ delete [] planes[2];
+}
+
+} // namespace remoting
Property changes on: remoting/host/encoder_vp8_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « remoting/host/encoder_vp8.cc ('k') | remoting/host/event_executor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698