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

Unified Diff: ui/compositor/compositor_unittest.cc

Issue 1081223002: Use MessageLoop for CompositorTest.LocksTimeOut (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@impl
Patch Set: move constant to header Created 5 years, 8 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.cc ('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
index 6b42e62199f5505dd9ba90fc2efae6ea25044cec..c64b8ce464abb2fbb5292ee7f5515552b55ce71d 100644
--- a/ui/compositor/compositor_unittest.cc
+++ b/ui/compositor/compositor_unittest.cc
@@ -2,7 +2,8 @@
// 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 "base/message_loop/message_loop_proxy.h"
+#include "base/run_loop.h"
#include "cc/output/begin_frame_args.h"
#include "cc/test/begin_frame_args_test.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -29,7 +30,7 @@ class CompositorTest : public testing::Test {
~CompositorTest() override {}
void SetUp() override {
- task_runner_ = new base::TestSimpleTaskRunner;
+ task_runner_ = base::MessageLoopProxy::current();
danakj 2015/04/21 21:18:28 This should be ThreadTaskRunnerHandle::Get()
ui::ContextFactory* context_factory =
ui::InitializeContextFactoryForTests(false);
@@ -43,11 +44,11 @@ class CompositorTest : public testing::Test {
}
protected:
- base::TestSimpleTaskRunner* task_runner() { return task_runner_.get(); }
+ base::MessageLoopProxy* task_runner() { return task_runner_.get(); }
danakj 2015/04/21 21:18:28 This should be a SingleThreadTaskRunner, MLP is de
ui::Compositor* compositor() { return compositor_.get(); }
private:
- scoped_refptr<base::TestSimpleTaskRunner> task_runner_;
+ scoped_refptr<base::MessageLoopProxy> task_runner_;
danakj 2015/04/21 21:18:28 This should be SingleThreadTaskRunner too
scoped_ptr<ui::Compositor> compositor_;
DISALLOW_COPY_AND_ASSIGN(CompositorTest);
@@ -57,19 +58,30 @@ class CompositorTest : public testing::Test {
TEST_F(CompositorTest, LocksTimeOut) {
scoped_refptr<ui::CompositorLock> lock;
+ {
+ base::RunLoop run_loop;
+ // Ensure that the lock times out by default.
+ lock = compositor()->GetCompositorLock();
+ EXPECT_TRUE(compositor()->IsLocked());
+ task_runner()->PostDelayedTask(
+ FROM_HERE, run_loop.QuitClosure(),
+ base::TimeDelta::FromMilliseconds(kCompositorLockTimeoutMs));
+ run_loop.Run();
+ EXPECT_FALSE(compositor()->IsLocked());
+ }
- // 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());
+ {
+ base::RunLoop run_loop;
+ // Ensure that the lock does not time out when set.
+ compositor()->SetLocksWillTimeOut(false);
+ lock = compositor()->GetCompositorLock();
+ EXPECT_TRUE(compositor()->IsLocked());
+ task_runner()->PostDelayedTask(
+ FROM_HERE, run_loop.QuitClosure(),
+ base::TimeDelta::FromMilliseconds(kCompositorLockTimeoutMs));
+ run_loop.Run();
+ EXPECT_TRUE(compositor()->IsLocked());
+ }
}
TEST_F(CompositorTest, AddAndRemoveBeginFrameObserver) {
« no previous file with comments | « ui/compositor/compositor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698