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

Side by Side Diff: third_party/WebKit/Source/core/dom/MainThreadTaskRunnerTest.cpp

Issue 1938313003: Move MainThreadTaskRunner off Oilpan heap to simplify posting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile fix Created 4 years, 6 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 unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 namespace blink { 39 namespace blink {
40 40
41 static void markBoolean(bool* toBeMarked) 41 static void markBoolean(bool* toBeMarked)
42 { 42 {
43 *toBeMarked = true; 43 *toBeMarked = true;
44 } 44 }
45 45
46 TEST(MainThreadTaskRunnerTest, PostTask) 46 TEST(MainThreadTaskRunnerTest, PostTask)
47 { 47 {
48 NullExecutionContext* context = new NullExecutionContext(); 48 NullExecutionContext* context = new NullExecutionContext();
49 MainThreadTaskRunner* runner = MainThreadTaskRunner::create(context); 49 OwnPtr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(context);
50 bool isMarked = false; 50 bool isMarked = false;
51 51
52 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, &isMark ed)); 52 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, &isMark ed));
53 EXPECT_FALSE(isMarked); 53 EXPECT_FALSE(isMarked);
54 blink::testing::runPendingTasks(); 54 blink::testing::runPendingTasks();
55 EXPECT_TRUE(isMarked); 55 EXPECT_TRUE(isMarked);
56 } 56 }
57 57
58 TEST(MainThreadTaskRunnerTest, SuspendTask) 58 TEST(MainThreadTaskRunnerTest, SuspendTask)
59 { 59 {
60 NullExecutionContext* context = new NullExecutionContext(); 60 NullExecutionContext* context = new NullExecutionContext();
61 MainThreadTaskRunner* runner = MainThreadTaskRunner::create(context); 61 OwnPtr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(context);
62 bool isMarked = false; 62 bool isMarked = false;
63 63
64 context->setTasksNeedSuspension(true); 64 context->setTasksNeedSuspension(true);
65 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, &isMark ed)); 65 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, &isMark ed));
66 runner->suspend(); 66 runner->suspend();
67 blink::testing::runPendingTasks(); 67 blink::testing::runPendingTasks();
68 EXPECT_FALSE(isMarked); 68 EXPECT_FALSE(isMarked);
69 69
70 context->setTasksNeedSuspension(false); 70 context->setTasksNeedSuspension(false);
71 runner->resume(); 71 runner->resume();
72 blink::testing::runPendingTasks(); 72 blink::testing::runPendingTasks();
73 EXPECT_TRUE(isMarked); 73 EXPECT_TRUE(isMarked);
74 } 74 }
75 75
76 TEST(MainThreadTaskRunnerTest, RemoveRunner) 76 TEST(MainThreadTaskRunnerTest, RemoveRunner)
77 { 77 {
78 NullExecutionContext* context = new NullExecutionContext(); 78 NullExecutionContext* context = new NullExecutionContext();
79 MainThreadTaskRunner* runner = MainThreadTaskRunner::create(context); 79 OwnPtr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(context);
80 bool isMarked = false; 80 bool isMarked = false;
81 81
82 context->setTasksNeedSuspension(true); 82 context->setTasksNeedSuspension(true);
83 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, &isMark ed)); 83 runner->postTask(BLINK_FROM_HERE, createSameThreadTask(&markBoolean, &isMark ed));
84 runner = nullptr; 84 runner = nullptr;
85 blink::testing::runPendingTasks(); 85 blink::testing::runPendingTasks();
86 EXPECT_FALSE(isMarked); 86 EXPECT_FALSE(isMarked);
87 } 87 }
88 88
89 } // namespace blink 89 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698