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

Side by Side Diff: cc/output/begin_frame_args_unittest.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « cc/output/begin_frame_args.cc ('k') | cc/output/delegating_renderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 <string> 5 #include <string>
6 6
7 #include "cc/output/begin_frame_args.h" 7 #include "cc/output/begin_frame_args.h"
8 #include "cc/test/begin_frame_args_test.h" 8 #include "cc/test/begin_frame_args_test.h"
9 #include "testing/gtest/include/gtest/gtest-spi.h" 9 #include "testing/gtest/include/gtest/gtest-spi.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/gfx/frame_time.h" 11 #include "ui/gfx/frame_time.h"
12 12
13 namespace cc { 13 namespace cc {
14 namespace { 14 namespace {
15 15
16 TEST(BeginFrameArgsTest, Helpers) { 16 TEST(BeginFrameArgsTest, Helpers) {
17 // Quick create methods work 17 // Quick create methods work
18 BeginFrameArgs args0 = CreateBeginFrameArgsForTesting(); 18 BeginFrameArgs args0 = CreateBeginFrameArgsForTesting();
19 EXPECT_TRUE(args0.IsValid()) << args0; 19 EXPECT_TRUE(args0.IsValid()) << args0;
20 20
21 BeginFrameArgs args1 = CreateBeginFrameArgsForTesting(0, 0, -1); 21 BeginFrameArgs args1 = CreateBeginFrameArgsForTesting(0, 0, -1);
22 EXPECT_FALSE(args1.IsValid()) << args1; 22 EXPECT_FALSE(args1.IsValid()) << args1;
23 23
24 BeginFrameArgs args2 = CreateBeginFrameArgsForTesting(1, 2, 3); 24 BeginFrameArgs args2 = CreateBeginFrameArgsForTesting(1, 2, 3);
25 EXPECT_TRUE(args2.IsValid()) << args2; 25 EXPECT_TRUE(args2.IsValid()) << args2;
26 EXPECT_EQ(1, args2.frame_time.ToInternalValue()); 26 EXPECT_EQ(1, args2.frame_time.ToInternalValue());
27 EXPECT_EQ(2, args2.deadline.ToInternalValue()); 27 EXPECT_EQ(2, args2.deadline.ToInternalValue());
28 EXPECT_EQ(3, args2.interval.ToInternalValue()); 28 EXPECT_EQ(3, args2.interval.ToInternalValue());
29 EXPECT_EQ(BeginFrameArgs::NORMAL, args2.type);
29 30
30 BeginFrameArgs args3 = CreateExpiredBeginFrameArgsForTesting(); 31 BeginFrameArgs args3 = CreateExpiredBeginFrameArgsForTesting();
31 EXPECT_TRUE(args3.IsValid()) << args3; 32 EXPECT_TRUE(args3.IsValid()) << args3;
32 EXPECT_GT(gfx::FrameTime::Now(), args3.deadline); 33 EXPECT_GT(gfx::FrameTime::Now(), args3.deadline);
34 EXPECT_EQ(BeginFrameArgs::NORMAL, args3.type);
35
36 BeginFrameArgs args4 =
37 CreateBeginFrameArgsForTesting(1, 2, 3, BeginFrameArgs::MISSED);
38 EXPECT_TRUE(args4.IsValid()) << args4;
39 EXPECT_EQ(1, args4.frame_time.ToInternalValue());
40 EXPECT_EQ(2, args4.deadline.ToInternalValue());
41 EXPECT_EQ(3, args4.interval.ToInternalValue());
42 EXPECT_EQ(BeginFrameArgs::MISSED, args4.type);
33 43
34 // operator== 44 // operator==
35 EXPECT_EQ(CreateBeginFrameArgsForTesting(4, 5, 6), 45 EXPECT_EQ(CreateBeginFrameArgsForTesting(4, 5, 6),
36 CreateBeginFrameArgsForTesting(4, 5, 6)); 46 CreateBeginFrameArgsForTesting(4, 5, 6));
37 47
48 EXPECT_NONFATAL_FAILURE(
49 EXPECT_EQ(CreateBeginFrameArgsForTesting(7, 8, 9, BeginFrameArgs::MISSED),
50 CreateBeginFrameArgsForTesting(7, 8, 9)),
51 "");
38 EXPECT_NONFATAL_FAILURE(EXPECT_EQ(CreateBeginFrameArgsForTesting(4, 5, 6), 52 EXPECT_NONFATAL_FAILURE(EXPECT_EQ(CreateBeginFrameArgsForTesting(4, 5, 6),
39 CreateBeginFrameArgsForTesting(7, 8, 9)), 53 CreateBeginFrameArgsForTesting(7, 8, 9)),
40 ""); 54 "");
41 55
42 // operator<< 56 // operator<<
43 std::stringstream out1; 57 std::stringstream out1;
44 out1 << args1; 58 out1 << args1;
45 EXPECT_EQ("BeginFrameArgs(0, 0, -1us)", out1.str()); 59 EXPECT_EQ("BeginFrameArgs(NORMAL, 0, 0, -1us)", out1.str());
46 std::stringstream out2; 60 std::stringstream out2;
47 out2 << args2; 61 out2 << args2;
48 EXPECT_EQ("BeginFrameArgs(1, 2, 3us)", out2.str()); 62 EXPECT_EQ("BeginFrameArgs(NORMAL, 1, 2, 3us)", out2.str());
49 63
50 // PrintTo 64 // PrintTo
51 EXPECT_EQ(std::string("BeginFrameArgs(0, 0, -1us)"), 65 EXPECT_EQ(std::string("BeginFrameArgs(NORMAL, 0, 0, -1us)"),
52 ::testing::PrintToString(args1)); 66 ::testing::PrintToString(args1));
53 EXPECT_EQ(std::string("BeginFrameArgs(1, 2, 3us)"), 67 EXPECT_EQ(std::string("BeginFrameArgs(NORMAL, 1, 2, 3us)"),
54 ::testing::PrintToString(args2)); 68 ::testing::PrintToString(args2));
55 } 69 }
56 70
57 TEST(BeginFrameArgsTest, Create) { 71 TEST(BeginFrameArgsTest, Create) {
58 // BeginFrames are not valid by default 72 // BeginFrames are not valid by default
59 BeginFrameArgs args1; 73 BeginFrameArgs args1;
60 EXPECT_FALSE(args1.IsValid()) << args1; 74 EXPECT_FALSE(args1.IsValid()) << args1;
61 75
62 BeginFrameArgs args2 = 76 BeginFrameArgs args2 = BeginFrameArgs::Create(
63 BeginFrameArgs::Create(base::TimeTicks::FromInternalValue(1), 77 base::TimeTicks::FromInternalValue(1),
64 base::TimeTicks::FromInternalValue(2), 78 base::TimeTicks::FromInternalValue(2),
65 base::TimeDelta::FromInternalValue(3)); 79 base::TimeDelta::FromInternalValue(3), BeginFrameArgs::NORMAL);
66 EXPECT_TRUE(args2.IsValid()) << args2; 80 EXPECT_TRUE(args2.IsValid()) << args2;
67 EXPECT_EQ(1, args2.frame_time.ToInternalValue()) << args2; 81 EXPECT_EQ(1, args2.frame_time.ToInternalValue()) << args2;
68 EXPECT_EQ(2, args2.deadline.ToInternalValue()) << args2; 82 EXPECT_EQ(2, args2.deadline.ToInternalValue()) << args2;
69 EXPECT_EQ(3, args2.interval.ToInternalValue()) << args2; 83 EXPECT_EQ(3, args2.interval.ToInternalValue()) << args2;
70 84 EXPECT_EQ(BeginFrameArgs::NORMAL, args2.type) << args2;
71 base::TimeTicks now = base::TimeTicks::FromInternalValue(1);
72 EXPECT_EQ(CreateBeginFrameArgsForTesting(1, 0, 16666),
73 BeginFrameArgs::CreateForSynchronousCompositor(now));
74 } 85 }
75 86
76 } // namespace 87 } // namespace
77 } // namespace cc 88 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/begin_frame_args.cc ('k') | cc/output/delegating_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698