[safe_browsing] Remove unused ContainsBrowseUrl() parameter.
[chromium-blink-merge.git] / content / child / worker_task_runner_unittest.cc
blob530c8a2f17885dacd1b0e9c76929ca0959d15172
1 // Copyright 2014 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 "content/child/worker_task_runner.h"
7 #include "base/logging.h"
8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h"
11 namespace content {
13 class WorkerTaskRunnerTest : public testing::Test {
14 public:
15 void FakeStart() {
16 task_runner_.OnWorkerRunLoopStarted(blink::WebWorkerRunLoop());
18 void FakeStop() {
19 task_runner_.OnWorkerRunLoopStopped(blink::WebWorkerRunLoop());
21 WorkerTaskRunner task_runner_;
24 class MockObserver : public WorkerTaskRunner::Observer {
25 public:
26 MOCK_METHOD0(OnWorkerRunLoopStopped, void());
27 void RemoveSelfOnNotify() {
28 ON_CALL(*this, OnWorkerRunLoopStopped()).WillByDefault(
29 testing::Invoke(this, &MockObserver::RemoveSelf));
31 void RemoveSelf() {
32 runner_->RemoveStopObserver(this);
34 WorkerTaskRunner* runner_;
37 TEST_F(WorkerTaskRunnerTest, BasicObservingAndWorkerId) {
38 ASSERT_EQ(0, task_runner_.CurrentWorkerId());
39 MockObserver o;
40 EXPECT_CALL(o, OnWorkerRunLoopStopped()).Times(1);
41 FakeStart();
42 task_runner_.AddStopObserver(&o);
43 ASSERT_LT(0, task_runner_.CurrentWorkerId());
44 FakeStop();
47 TEST_F(WorkerTaskRunnerTest, CanRemoveSelfDuringNotification) {
48 MockObserver o;
49 o.RemoveSelfOnNotify();
50 o.runner_ = &task_runner_;
51 EXPECT_CALL(o, OnWorkerRunLoopStopped()).Times(1);
52 FakeStart();
53 task_runner_.AddStopObserver(&o);
54 FakeStop();
57 } // namespace content