Implement MoveFileLocal (with creating a snapshot).
[chromium-blink-merge.git] / ui / compositor / compositor_unittest.cc
blob810f1c96d0875938de0b2460aaddcb4eaf4568f4
1 // Copyright 2015 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.
5 #include "base/test/test_simple_task_runner.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "ui/compositor/compositor.h"
8 #include "ui/compositor/test/context_factories_for_test.h"
10 namespace ui {
11 namespace {
13 // Test fixture for tests that require a ui::Compositor with a real task
14 // runner.
15 class CompositorTest : public testing::Test {
16 public:
17 CompositorTest() {}
18 ~CompositorTest() override {}
20 void SetUp() override {
21 task_runner_ = new base::TestSimpleTaskRunner;
23 ui::ContextFactory* context_factory =
24 ui::InitializeContextFactoryForTests(false);
26 compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget,
27 context_factory, task_runner_));
29 void TearDown() override {
30 compositor_.reset();
31 ui::TerminateContextFactoryForTests();
34 protected:
35 base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); }
36 ui::Compositor* compositor() { return compositor_.get(); }
38 private:
39 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
40 scoped_ptr<ui::Compositor> compositor_;
42 DISALLOW_COPY_AND_ASSIGN(CompositorTest);
45 } // namespace
47 TEST_F(CompositorTest, LocksTimeOut) {
48 scoped_refptr<ui::CompositorLock> lock;
50 // Ensure that the lock times out by default.
51 lock = compositor()->GetCompositorLock();
52 EXPECT_TRUE(compositor()->IsLocked());
53 task_runner()->RunUntilIdle();
54 EXPECT_FALSE(compositor()->IsLocked());
56 // Ensure that the lock does not time out when set.
57 compositor()->SetLocksWillTimeOut(false);
58 lock = compositor()->GetCompositorLock();
59 EXPECT_TRUE(compositor()->IsLocked());
60 task_runner()->RunUntilIdle();
61 EXPECT_TRUE(compositor()->IsLocked());
64 } // namespace ui