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.
4
5#include "ppapi/shared_impl/media_stream_video_track_shared.h"
6#include "testing/gtest/include/gtest/gtest.h"
7
8namespace ppapi {
9
10TEST(MediaStreamVideoTrackShared, Verify) {
11  {
12    MediaStreamVideoTrackShared::Attributes attributes;
13    EXPECT_TRUE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
14  }
15
16  // Verify buffers
17  {
18    MediaStreamVideoTrackShared::Attributes attributes;
19    attributes.buffers = 0;
20    EXPECT_TRUE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
21
22    attributes.buffers = 8;
23    EXPECT_TRUE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
24
25    attributes.buffers = 1024;
26    EXPECT_TRUE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
27
28    attributes.buffers = -1;
29    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
30  }
31
32  // Verify format
33  {
34    MediaStreamVideoTrackShared::Attributes attributes;
35    for (int32_t i = PP_VIDEOFRAME_FORMAT_UNKNOWN;
36         i <= PP_VIDEOFRAME_FORMAT_LAST;
37         ++i) {
38      attributes.format = static_cast<PP_VideoFrame_Format>(i);
39      EXPECT_TRUE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
40    }
41
42    attributes.format = static_cast<PP_VideoFrame_Format>(-1);
43    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
44
45    attributes.format =
46        static_cast<PP_VideoFrame_Format>(PP_VIDEOFRAME_FORMAT_LAST + 1);
47    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
48  }
49
50  // Verify width
51  {
52    MediaStreamVideoTrackShared::Attributes attributes;
53    attributes.width = 1024;
54    EXPECT_TRUE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
55
56    attributes.width = 1025;
57    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
58
59    attributes.width = 1026;
60    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
61
62    attributes.width = -1;
63    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
64
65    attributes.width = -4;
66    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
67
68    attributes.width = 4097;
69    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
70  }
71
72  // Verify height
73  {
74    MediaStreamVideoTrackShared::Attributes attributes;
75    attributes.height = 1024;
76    EXPECT_TRUE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
77
78    attributes.height = 1025;
79    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
80
81    attributes.height = 1026;
82    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
83
84    attributes.height = -1;
85    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
86
87    attributes.height = -4;
88    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
89
90    attributes.height = 4096 + 4;
91    EXPECT_FALSE(MediaStreamVideoTrackShared::VerifyAttributes(attributes));
92  }
93
94}
95
96}  // namespace ppapi
97