This sets up API to release OutputSurface from LTHClient.
[chromium-blink-merge.git] / media / cast / test / utility / barcode_unittest.cc
blob04e43f5a0978158249513d281eac6c3e4331223f
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
3 // found in the LICENSE file.
5 #include "media/base/video_frame.h"
6 #include "media/cast/test/utility/barcode.h"
7 #include "testing/gtest/include/gtest/gtest.h"
9 namespace media {
10 namespace cast {
11 namespace test {
12 namespace {
14 TEST(BarcodeTest, Small) {
15 scoped_refptr<media::VideoFrame> frame =
16 media::VideoFrame::CreateBlackFrame(gfx::Size(320, 10));
17 for (unsigned char in_bits = 0; in_bits < 255; in_bits++) {
18 EXPECT_TRUE(EncodeBarcode(in_bits, frame));
19 unsigned char out_bits = ~in_bits;
20 EXPECT_TRUE(DecodeBarcode(frame, &out_bits));
21 EXPECT_EQ(in_bits, out_bits);
25 TEST(BarcodeTest, Large) {
26 scoped_refptr<media::VideoFrame> frame =
27 media::VideoFrame::CreateBlackFrame(gfx::Size(10000, 10));
28 std::vector<bool> in_bits(1024);
29 std::vector<bool> out_bits(1024);
30 for (int i = 0; i < 1024; i++) in_bits[i] = true;
31 EXPECT_TRUE(EncodeBarcode(in_bits, frame));
32 EXPECT_TRUE(DecodeBarcode(frame, &out_bits));
33 for (int i = 0; i < 1024; i++) {
34 EXPECT_EQ(in_bits[i], out_bits[i]);
37 for (int i = 0; i < 1024; i++) in_bits[i] = false;
38 EXPECT_TRUE(EncodeBarcode(in_bits, frame));
39 EXPECT_TRUE(DecodeBarcode(frame, &out_bits));
40 for (int i = 0; i < 1024; i++) {
41 EXPECT_EQ(in_bits[i], out_bits[i]);
44 for (int i = 0; i < 1024; i++) in_bits[i] = (i & 1) == 0;
45 EXPECT_TRUE(EncodeBarcode(in_bits, frame));
46 EXPECT_TRUE(DecodeBarcode(frame, &out_bits));
47 for (int i = 0; i < 1024; i++) {
48 EXPECT_EQ(in_bits[i], out_bits[i]);
51 for (int i = 0; i < 1024; i++) in_bits[i] = (i & 1) == 1;
52 EXPECT_TRUE(EncodeBarcode(in_bits, frame));
53 EXPECT_TRUE(DecodeBarcode(frame, &out_bits));
54 for (int i = 0; i < 1024; i++) {
55 EXPECT_EQ(in_bits[i], out_bits[i]);
59 } // namespace
60 } // namespace test
61 } // namespace cast
62 } // namespace media