summaryrefslogtreecommitdiffstats
path: root/chrome/test/thread_test_helper.cc
blob: 6714310b80323e9b8bf5fb3782724a79ff24c2f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Copyright (c) 2011 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 "chrome/test/thread_test_helper.h"

ThreadTestHelper::ThreadTestHelper(BrowserThread::ID thread_id)
    : test_result_(false),
      thread_id_(thread_id),
      done_event_(false, false) {
}

bool ThreadTestHelper::Run() {
  if (!BrowserThread::PostTask(thread_id_, FROM_HERE, NewRunnableMethod(
          this, &ThreadTestHelper::RunInThread))) {
    return false;
  }
  done_event_.Wait();
  return test_result_;
}

void ThreadTestHelper::RunTest() { set_test_result(true); }

ThreadTestHelper::~ThreadTestHelper() {}

void ThreadTestHelper::RunInThread() {
  RunTest();
  done_event_.Signal();
}