blob: e184ceb0c51090c5a48156a88af187eaa5f4923a [file] [log] [blame]
[email protected]ef948e62012-09-04 22:27:431// Copyright (c) 2012 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/bind.h"
6#include "base/memory/ref_counted.h"
[email protected]f368eeb2013-07-17 23:53:327#include "base/message_loop/message_loop.h"
[email protected]ef948e62012-09-04 22:27:438#include "remoting/base/auto_thread_task_runner.h"
9#include "testing/gtest/include/gtest/gtest.h"
10
11namespace {
12
[email protected]3d871d92012-12-07 07:36:4513void SetFlagTask(bool* success) {
[email protected]ef948e62012-09-04 22:27:4314 *success = true;
15}
16
17} // namespace
18
19namespace remoting {
20
[email protected]3d871d92012-12-07 07:36:4521TEST(AutoThreadTaskRunnerTest, StartAndStop) {
[email protected]ef948e62012-09-04 22:27:4322 // Create a task runner.
[email protected]faea9d2d2013-04-30 03:18:4423 base::MessageLoop message_loop;
24 scoped_refptr<AutoThreadTaskRunner> task_runner = new AutoThreadTaskRunner(
25 message_loop.message_loop_proxy(), base::MessageLoop::QuitClosure());
[email protected]ef948e62012-09-04 22:27:4326
27 // Post a task to make sure it is executed.
28 bool success = false;
[email protected]3d871d92012-12-07 07:36:4529 message_loop.PostTask(FROM_HERE, base::Bind(&SetFlagTask, &success));
[email protected]ef948e62012-09-04 22:27:4330
31 task_runner = NULL;
32 message_loop.Run();
33 EXPECT_TRUE(success);
34}
35
[email protected]ef948e62012-09-04 22:27:4336} // namespace remoting