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

Unified Diff: ui/compositor/compositor_unittest.cc

Issue 996453002: Allow ui::Compositor to disable commits during tab-switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporate review feedback 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
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/compositor_unittest.cc
diff --git a/ui/compositor/compositor_unittest.cc b/ui/compositor/compositor_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..810f1c96d0875938de0b2460aaddcb4eaf4568f4
--- /dev/null
+++ b/ui/compositor/compositor_unittest.cc
@@ -0,0 +1,64 @@
+// 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/test/test_simple_task_runner.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/compositor/compositor.h"
+#include "ui/compositor/test/context_factories_for_test.h"
+
+namespace ui {
+namespace {
+
+// Test fixture for tests that require a ui::Compositor with a real task
+// runner.
+class CompositorTest : public testing::Test {
+ public:
+ CompositorTest() {}
+ ~CompositorTest() override {}
+
+ void SetUp() override {
+ task_runner_ = new base::TestSimpleTaskRunner;
+
+ ui::ContextFactory* context_factory =
+ ui::InitializeContextFactoryForTests(false);
+
+ compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget,
+ context_factory, task_runner_));
+ }
+ void TearDown() override {
+ compositor_.reset();
+ ui::TerminateContextFactoryForTests();
+ }
+
+ protected:
+ base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); }
+ ui::Compositor* compositor() { return compositor_.get(); }
+
+ private:
+ scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
+ scoped_ptr<ui::Compositor> compositor_;
+
+ DISALLOW_COPY_AND_ASSIGN(CompositorTest);
+};
+
+} // namespace
+
+TEST_F(CompositorTest, LocksTimeOut) {
+ scoped_refptr<ui::CompositorLock> lock;
+
+ // Ensure that the lock times out by default.
+ lock = compositor()->GetCompositorLock();
+ EXPECT_TRUE(compositor()->IsLocked());
+ task_runner()->RunUntilIdle();
+ EXPECT_FALSE(compositor()->IsLocked());
+
+ // Ensure that the lock does not time out when set.
+ compositor()->SetLocksWillTimeOut(false);
+ lock = compositor()->GetCompositorLock();
+ EXPECT_TRUE(compositor()->IsLocked());
+ task_runner()->RunUntilIdle();
+ EXPECT_TRUE(compositor()->IsLocked());
+}
+
+} // namespace ui
« no previous file with comments | « ui/compositor/compositor.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698