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

Unified Diff: content/browser/renderer_host/begin_frame_manager_unittest.cc

Issue 1000503002: Add BeginFrameObserverProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add BeginFrameManager Created 5 years, 9 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
Index: content/browser/renderer_host/begin_frame_manager_unittest.cc
diff --git a/content/browser/renderer_host/begin_frame_manager_unittest.cc b/content/browser/renderer_host/begin_frame_manager_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..61b47d168505f8141501dec9bac7afb6e80c7ec3
--- /dev/null
+++ b/content/browser/renderer_host/begin_frame_manager_unittest.cc
@@ -0,0 +1,84 @@
+// Copyright 2015 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 "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/test/test_simple_task_runner.h"
+#include "cc/output/begin_frame_args.h"
+#include "cc/test/begin_frame_args_test.h"
+#include "content/browser/renderer_host/begin_frame_manager.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/compositor/compositor.h"
+#include "ui/compositor/test/context_factories_for_test.h"
+
+namespace content {
+namespace {
+
+class TestBeginFrameManagerClient : public BeginFrameManagerClient {
+ public:
+ TestBeginFrameManagerClient() : begin_frame_sent_(false) {}
+ ~TestBeginFrameManagerClient() {}
+
+ // BeginFrameManagerClient:
+ void SendBeginFrame(const cc::BeginFrameArgs& args) override {
+ last_begin_frame_args_ = args;
+ begin_frame_sent_ = true;
+ }
+
+ bool begin_frame_sent() { return begin_frame_sent_; }
+ cc::BeginFrameArgs last_begin_frame_args() { return last_begin_frame_args_; }
+
+ private:
+ bool begin_frame_sent_;
+ cc::BeginFrameArgs last_begin_frame_args_;
+};
+
+class BeginFrameManagerTest : public testing::Test {
+ public:
+ BeginFrameManagerTest() {}
+ ~BeginFrameManagerTest() override {}
+
+ void SetUp() override {
+ bool enable_pixel_output = false;
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(enable_pixel_output);
+ compositor_task_runner_ = new base::TestSimpleTaskRunner();
+ compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget,
+ context_factory,
+ compositor_task_runner_));
+ }
+
+ void TearDown() override {
+ compositor_.reset();
+ ui::TerminateContextFactoryForTests();
+ }
+
+ ui::Compositor* compositor() { return compositor_.get(); }
+
+ private:
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner_;
+ scoped_ptr<ui::Compositor> compositor_;
+};
+
+} // namespace
+
+TEST_F(BeginFrameManagerTest, BeginFrameScheduling) {
+ TestBeginFrameManagerClient client;
+ BeginFrameManager begin_frame_manager(&client);
+ begin_frame_manager.SetCompositor(compositor());
danakj 2015/03/17 18:56:45 Shall we also test setting the compositor to null
brianderson 2015/03/17 22:29:32 +1
simonhong 2015/03/19 15:48:46 Done.
+ begin_frame_manager.OnSetNeedsBeginFrames(true);
+ EXPECT_FALSE(client.begin_frame_sent());
+
+ cc::BeginFrameArgs args =
+ cc::CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE,
+ base::TimeTicks::FromInternalValue(33));
+ compositor()->SendBeginFramesToChildren(args);
+ EXPECT_TRUE(client.begin_frame_sent());
+ EXPECT_EQ(args.frame_time, client.last_begin_frame_args().frame_time);
+
+ begin_frame_manager.ResetCompositor();
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698