OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2013 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2013 Google Inc. All Rights Reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 30 matching lines...) Expand all Loading... |
41 { | 41 { |
42 *toBeMarked = true; | 42 *toBeMarked = true; |
43 } | 43 } |
44 | 44 |
45 TEST(MainThreadTaskRunnerTest, PostTask) | 45 TEST(MainThreadTaskRunnerTest, PostTask) |
46 { | 46 { |
47 NullExecutionContext* context = new NullExecutionContext(); | 47 NullExecutionContext* context = new NullExecutionContext(); |
48 std::unique_ptr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(
context); | 48 std::unique_ptr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(
context); |
49 bool isMarked = false; | 49 bool isMarked = false; |
50 | 50 |
51 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, &isMark
ed)); | 51 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, WTF::un
retained(&isMarked))); |
52 EXPECT_FALSE(isMarked); | 52 EXPECT_FALSE(isMarked); |
53 blink::testing::runPendingTasks(); | 53 blink::testing::runPendingTasks(); |
54 EXPECT_TRUE(isMarked); | 54 EXPECT_TRUE(isMarked); |
55 } | 55 } |
56 | 56 |
57 TEST(MainThreadTaskRunnerTest, SuspendTask) | 57 TEST(MainThreadTaskRunnerTest, SuspendTask) |
58 { | 58 { |
59 NullExecutionContext* context = new NullExecutionContext(); | 59 NullExecutionContext* context = new NullExecutionContext(); |
60 std::unique_ptr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(
context); | 60 std::unique_ptr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(
context); |
61 bool isMarked = false; | 61 bool isMarked = false; |
62 | 62 |
63 context->setTasksNeedSuspension(true); | 63 context->setTasksNeedSuspension(true); |
64 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, &isMark
ed)); | 64 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, WTF::un
retained(&isMarked))); |
65 runner->suspend(); | 65 runner->suspend(); |
66 blink::testing::runPendingTasks(); | 66 blink::testing::runPendingTasks(); |
67 EXPECT_FALSE(isMarked); | 67 EXPECT_FALSE(isMarked); |
68 | 68 |
69 context->setTasksNeedSuspension(false); | 69 context->setTasksNeedSuspension(false); |
70 runner->resume(); | 70 runner->resume(); |
71 blink::testing::runPendingTasks(); | 71 blink::testing::runPendingTasks(); |
72 EXPECT_TRUE(isMarked); | 72 EXPECT_TRUE(isMarked); |
73 } | 73 } |
74 | 74 |
75 TEST(MainThreadTaskRunnerTest, RemoveRunner) | 75 TEST(MainThreadTaskRunnerTest, RemoveRunner) |
76 { | 76 { |
77 NullExecutionContext* context = new NullExecutionContext(); | 77 NullExecutionContext* context = new NullExecutionContext(); |
78 std::unique_ptr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(
context); | 78 std::unique_ptr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(
context); |
79 bool isMarked = false; | 79 bool isMarked = false; |
80 | 80 |
81 context->setTasksNeedSuspension(true); | 81 context->setTasksNeedSuspension(true); |
82 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, &isMark
ed)); | 82 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, WTF::un
retained(&isMarked))); |
83 runner = nullptr; | 83 runner = nullptr; |
84 blink::testing::runPendingTasks(); | 84 blink::testing::runPendingTasks(); |
85 EXPECT_FALSE(isMarked); | 85 EXPECT_FALSE(isMarked); |
86 } | 86 } |
87 | 87 |
88 } // namespace blink | 88 } // namespace blink |
OLD | NEW |