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

Side by Side 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: Cleaned up version 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 unified diff | Download patch
« ui/compositor/compositor.cc ('K') | « ui/compositor/compositor.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
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"
9
10 namespace ui {
11 namespace {
12
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 {}
19
20 void SetUp() override {
21 task_runner_ = new base::TestSimpleTaskRunner;
22
23 ui::ContextFactory* context_factory =
24 ui::InitializeContextFactoryForTests(false);
25
26 compositor_.reset(new ui::Compositor(gfx::kNullAcceleratedWidget,
27 context_factory, task_runner_));
28 }
29 void TearDown() override {
30 compositor_.reset();
31 ui::TerminateContextFactoryForTests();
32 }
33
34 protected:
35 base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); }
36 ui::Compositor* compositor() { return compositor_.get(); }
37
38 private:
39 scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
40 scoped_ptr<ui::Compositor> compositor_;
41
42 DISALLOW_COPY_AND_ASSIGN(CompositorTest);
43 };
44
45 } // namespace
46
47 TEST_F(CompositorTest, LocksTimeOut) {
48 scoped_refptr<ui::CompositorLock> lock;
49
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());
55
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());
62 }
63
64 } // namespace ui
OLDNEW
« ui/compositor/compositor.cc ('K') | « ui/compositor/compositor.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698