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

Unified Diff: cc/output/begin_frame_args_unittest.cc

Issue 273823002: Adding gtest helpers for BeginFrameArgs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change EXPECT_EQ(true/false to EXPECT_TRUE/FALSE(. Created 6 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/output/begin_frame_args.cc ('k') | cc/test/begin_frame_args_test.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/begin_frame_args_unittest.cc
diff --git a/cc/output/begin_frame_args_unittest.cc b/cc/output/begin_frame_args_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4dce5e0ef5930ca8bd6141973b8cda9871a06c6d
--- /dev/null
+++ b/cc/output/begin_frame_args_unittest.cc
@@ -0,0 +1,77 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <string>
+
+#include "cc/output/begin_frame_args.h"
+#include "cc/test/begin_frame_args_test.h"
+#include "testing/gtest/include/gtest/gtest-spi.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/frame_time.h"
+
+namespace cc {
+namespace {
+
+TEST(BeginFrameArgsTest, Helpers) {
+ // Quick create methods work
+ BeginFrameArgs args0 = CreateBeginFrameArgsForTesting();
+ EXPECT_TRUE(args0.IsValid()) << args0;
+
+ BeginFrameArgs args1 = CreateBeginFrameArgsForTesting(0, 0, -1);
+ EXPECT_FALSE(args1.IsValid()) << args1;
+
+ BeginFrameArgs args2 = CreateBeginFrameArgsForTesting(1, 2, 3);
+ EXPECT_TRUE(args2.IsValid()) << args2;
+ EXPECT_EQ(1, args2.frame_time.ToInternalValue());
+ EXPECT_EQ(2, args2.deadline.ToInternalValue());
+ EXPECT_EQ(3, args2.interval.ToInternalValue());
+
+ BeginFrameArgs args3 = CreateExpiredBeginFrameArgsForTesting();
+ EXPECT_TRUE(args3.IsValid()) << args3;
+ EXPECT_GT(gfx::FrameTime::Now(), args3.deadline);
+
+ // operator==
+ EXPECT_EQ(CreateBeginFrameArgsForTesting(4, 5, 6),
+ CreateBeginFrameArgsForTesting(4, 5, 6));
+
+ EXPECT_NONFATAL_FAILURE(EXPECT_EQ(CreateBeginFrameArgsForTesting(4, 5, 6),
+ CreateBeginFrameArgsForTesting(7, 8, 9)),
+ "");
+
+ // operator<<
+ std::stringstream out1;
+ out1 << args1;
+ EXPECT_EQ("BeginFrameArgs(0, 0, -1us)", out1.str());
+ std::stringstream out2;
+ out2 << args2;
+ EXPECT_EQ("BeginFrameArgs(1, 2, 3us)", out2.str());
+
+ // PrintTo
+ EXPECT_EQ(std::string("BeginFrameArgs(0, 0, -1us)"),
+ ::testing::PrintToString(args1));
+ EXPECT_EQ(std::string("BeginFrameArgs(1, 2, 3us)"),
+ ::testing::PrintToString(args2));
+}
+
+TEST(BeginFrameArgsTest, Create) {
+ // BeginFrames are not valid by default
+ BeginFrameArgs args1;
+ EXPECT_FALSE(args1.IsValid()) << args1;
+
+ BeginFrameArgs args2 =
+ BeginFrameArgs::Create(base::TimeTicks::FromInternalValue(1),
+ base::TimeTicks::FromInternalValue(2),
+ base::TimeDelta::FromInternalValue(3));
+ EXPECT_TRUE(args2.IsValid()) << args2;
+ EXPECT_EQ(1, args2.frame_time.ToInternalValue()) << args2;
+ EXPECT_EQ(2, args2.deadline.ToInternalValue()) << args2;
+ EXPECT_EQ(3, args2.interval.ToInternalValue()) << args2;
+
+ base::TimeTicks now = base::TimeTicks::FromInternalValue(1);
+ EXPECT_EQ(CreateBeginFrameArgsForTesting(1, 0, 16666),
+ BeginFrameArgs::CreateForSynchronousCompositor(now));
+}
+
+} // namespace
+} // namespace cc
« no previous file with comments | « cc/output/begin_frame_args.cc ('k') | cc/test/begin_frame_args_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698