1 // Copyright 2019 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 "chrome/browser/media/webrtc/webrtc_browsertest_perf.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace test {
10
11 constexpr char kTypicalCompareVideosOutput[] =
12 "Adjusting test video with color transformation: \n"
13 " 1.00 0.01 0.01 -2.91 \n"
14 "-0.01 0.99 -0.04 7.21 \n"
15 " 0.00 -0.06 0.99 7.47 \n"
16 "RESULT Unique_frames_count: 360p_VP8= 80 score\n"
17 "RESULT PSNR: 360p_VP8= "
18 "[38.453419,38.453419,38.453419,38.453419,38.453419,38.453419,38.453419,38."
19 "453419,38.453419,38.453419,39.102536,39.102536,39.102536,39.767288,39."
20 "767288,39.767288,40.023144,40.023144,40.023144,40.562812,40.562812,40."
21 "562812,40.72701,40.72701,40.72701,40.72701,40.926442,40.926442,40.926442,"
22 "41.198192,41.198192,41.198192,41.397378,41.397378,41.397378,41.435832,41."
23 "435832,41.435832,41.456998,41.456998,41.456998,41.66108,41.66108,41.66108,"
24 "41.722977,41.722977,41.722977,41.471985,41.471985,41.471985,41.471985,41."
25 "471985,41.263275,41.263275,41.263275,40.953795,40.953795,40.890606,40."
26 "890606,40.890606,41.055124,41.055124,41.055124,41.371183,41.371183,41."
27 "371183,41.64044,41.64044,41.64044,41.64044,41.64044,41.725886,41.725886,"
28 "41.725886,41.578544,41.578544,41.646766,41.646766,41.490909,41.490909] "
29 "dB\n"
30 "RESULT SSIM: 360p_VP8= "
31 "[0.96503067,0.96503067,0.96503067,0.96503067,0.96503067,0.96503067,0."
32 "96503067,0.96503067,0.96503067,0.96503067,0.96694655,0.96694655,0."
33 "96694655,0.97058175,0.97058175,0.97058175,0.97440174,0.97440174,0."
34 "97440174,0.97723814,0.97723814,0.97723814,0.97804682,0.97804682,0."
35 "97804682,0.97804682,0.98044036,0.98044036,0.98044036,0.98102023,0."
36 "98102023,0.98102023,0.98076329,0.98076329,0.98076329,0.98025288,0."
37 "98025288,0.98025288,0.98084894,0.98084894,0.98084894,0.98137786,0."
38 "98137786,0.98137786,0.9812953,0.9812953,0.9812953,0.97990543,0.97990543,0."
39 "97990543,0.97990543,0.97990543,0.97811092,0.97811092,0.97811092,0."
40 "97576317,0.97576317,0.97655883,0.97655883,0.97655883,0.97669573,0."
41 "97669573,0.97669573,0.9795819,0.9795819,0.9795819,0.98144956,0.98144956,0."
42 "98144956,0.98144956,0.98144956,0.98165894,0.98165894,0.98165894,0."
43 "98185588,0.98185588,0.98135814,0.98135814,0.98102463,0.98102463] score\n"
44 "RESULT Max_repeated: 360p_VP8= 10\n"
45 "RESULT Max_skipped: 360p_VP8= 1\n"
46 "RESULT Total_skipped: 360p_VP8= 23\n"
47 "RESULT Decode_errors_reference: 360p_VP8= 0\n"
48 "RESULT Decode_errors_test: 360p_VP8= 0\n";
49
TEST(WebrtcBrowserTestPerfTest,ParsesTypicalCompareVideosOutput)50 TEST(WebrtcBrowserTestPerfTest, ParsesTypicalCompareVideosOutput) {
51 EXPECT_TRUE(WriteCompareVideosOutputAsHistogram("someLabel",
52 kTypicalCompareVideosOutput));
53 }
54
TEST(WebrtcBrowserTestPerfTest,FailsOnWrongNumberOfLines)55 TEST(WebrtcBrowserTestPerfTest, FailsOnWrongNumberOfLines) {
56 EXPECT_FALSE(WriteCompareVideosOutputAsHistogram(
57 "whatever", "RESULT bad_label: 360p_VP8= 80 score\n"));
58 }
59
TEST(WebrtcBrowserTestPerfTest,FailsOnBadLabels)60 TEST(WebrtcBrowserTestPerfTest, FailsOnBadLabels) {
61 EXPECT_FALSE(WriteCompareVideosOutputAsHistogram(
62 "whatever", "RESULT bad_label: 360p_VP8= 80 score\na\nb\nc\nd\ne\nf\ng"));
63 }
64
TEST(WebrtcBrowserTestPerfTest,FailsOnBadValues)65 TEST(WebrtcBrowserTestPerfTest, FailsOnBadValues) {
66 EXPECT_FALSE(WriteCompareVideosOutputAsHistogram(
67 "whatever",
68 "RESULT bad_label: 360p_VP8= meh score\na\nb\nc\nd\ne\nf\ng"));
69 }
70
TEST(WebrtcBrowserTestPerfTest,FailsIfLabelsInWrongOrder)71 TEST(WebrtcBrowserTestPerfTest, FailsIfLabelsInWrongOrder) {
72 EXPECT_FALSE(WriteCompareVideosOutputAsHistogram(
73 "whatever", "RESULT PSNR: 360p_VP8= 80 score\na\nb\nc\nd\ne\nf\ng"));
74 }
75
76 } // namespace test
77