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.
7 #include "cc/output/begin_frame_args.h"
8 #include "cc/test/begin_frame_args_test.h"
9 #include "testing/gtest/include/gtest/gtest-spi.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/gfx/frame_time.h"
16 TEST(BeginFrameArgsTest
, Helpers
) {
17 // Quick create methods work
18 BeginFrameArgs args0
= CreateBeginFrameArgsForTesting();
19 EXPECT_TRUE(args0
.IsValid()) << args0
;
21 BeginFrameArgs args1
= CreateBeginFrameArgsForTesting(0, 0, -1);
22 EXPECT_FALSE(args1
.IsValid()) << args1
;
24 BeginFrameArgs args2
= CreateBeginFrameArgsForTesting(1, 2, 3);
25 EXPECT_TRUE(args2
.IsValid()) << args2
;
26 EXPECT_EQ(1, args2
.frame_time
.ToInternalValue());
27 EXPECT_EQ(2, args2
.deadline
.ToInternalValue());
28 EXPECT_EQ(3, args2
.interval
.ToInternalValue());
30 BeginFrameArgs args3
= CreateExpiredBeginFrameArgsForTesting();
31 EXPECT_TRUE(args3
.IsValid()) << args3
;
32 EXPECT_GT(gfx::FrameTime::Now(), args3
.deadline
);
35 EXPECT_EQ(CreateBeginFrameArgsForTesting(4, 5, 6),
36 CreateBeginFrameArgsForTesting(4, 5, 6));
38 EXPECT_NONFATAL_FAILURE(EXPECT_EQ(CreateBeginFrameArgsForTesting(4, 5, 6),
39 CreateBeginFrameArgsForTesting(7, 8, 9)),
43 std::stringstream out1
;
45 EXPECT_EQ("BeginFrameArgs(0, 0, -1us)", out1
.str());
46 std::stringstream out2
;
48 EXPECT_EQ("BeginFrameArgs(1, 2, 3us)", out2
.str());
51 EXPECT_EQ(std::string("BeginFrameArgs(0, 0, -1us)"),
52 ::testing::PrintToString(args1
));
53 EXPECT_EQ(std::string("BeginFrameArgs(1, 2, 3us)"),
54 ::testing::PrintToString(args2
));
57 TEST(BeginFrameArgsTest
, Create
) {
58 // BeginFrames are not valid by default
60 EXPECT_FALSE(args1
.IsValid()) << args1
;
62 BeginFrameArgs args2
=
63 BeginFrameArgs::Create(base::TimeTicks::FromInternalValue(1),
64 base::TimeTicks::FromInternalValue(2),
65 base::TimeDelta::FromInternalValue(3));
66 EXPECT_TRUE(args2
.IsValid()) << args2
;
67 EXPECT_EQ(1, args2
.frame_time
.ToInternalValue()) << args2
;
68 EXPECT_EQ(2, args2
.deadline
.ToInternalValue()) << args2
;
69 EXPECT_EQ(3, args2
.interval
.ToInternalValue()) << args2
;
71 base::TimeTicks now
= base::TimeTicks::FromInternalValue(1);
72 EXPECT_EQ(CreateBeginFrameArgsForTesting(1, 0, 16666),
73 BeginFrameArgs::CreateForSynchronousCompositor(now
));