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

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

Issue 1296243004: Oilpan: Move MainThreadTaskRunner into Oilpan heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Change WeakPtr to WeakPersistent in MainThreadTask. Created 5 years, 4 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 | Annotate | Revision Log
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 { 56 {
57 *m_toBeMarked = true; 57 *m_toBeMarked = true;
58 } 58 }
59 59
60 bool* m_toBeMarked; 60 bool* m_toBeMarked;
61 }; 61 };
62 62
63 TEST(MainThreadTaskRunnerTest, PostTask) 63 TEST(MainThreadTaskRunnerTest, PostTask)
64 { 64 {
65 RefPtrWillBeRawPtr<NullExecutionContext> context = adoptRefWillBeNoop(new Nu llExecutionContext()); 65 RefPtrWillBeRawPtr<NullExecutionContext> context = adoptRefWillBeNoop(new Nu llExecutionContext());
66 OwnPtr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(context.g et()); 66 OwnPtrWillBeRawPtr<MainThreadTaskRunner> runner = MainThreadTaskRunner::crea te(context.get());
67 bool isMarked = false; 67 bool isMarked = false;
68 68
69 runner->postTask(FROM_HERE, MarkingBooleanTask::create(&isMarked)); 69 runner->postTask(FROM_HERE, MarkingBooleanTask::create(&isMarked));
70 EXPECT_FALSE(isMarked); 70 EXPECT_FALSE(isMarked);
71 blink::testing::runPendingTasks(); 71 blink::testing::runPendingTasks();
72 EXPECT_TRUE(isMarked); 72 EXPECT_TRUE(isMarked);
73 } 73 }
74 74
75 TEST(MainThreadTaskRunnerTest, SuspendTask) 75 TEST(MainThreadTaskRunnerTest, SuspendTask)
76 { 76 {
77 RefPtrWillBeRawPtr<NullExecutionContext> context = adoptRefWillBeNoop(new Nu llExecutionContext()); 77 RefPtrWillBeRawPtr<NullExecutionContext> context = adoptRefWillBeNoop(new Nu llExecutionContext());
78 OwnPtr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(context.g et()); 78 OwnPtrWillBeRawPtr<MainThreadTaskRunner> runner = MainThreadTaskRunner::crea te(context.get());
79 bool isMarked = false; 79 bool isMarked = false;
80 80
81 context->setTasksNeedSuspension(true); 81 context->setTasksNeedSuspension(true);
82 runner->postTask(FROM_HERE, MarkingBooleanTask::create(&isMarked)); 82 runner->postTask(FROM_HERE, MarkingBooleanTask::create(&isMarked));
83 runner->suspend(); 83 runner->suspend();
84 blink::testing::runPendingTasks(); 84 blink::testing::runPendingTasks();
85 EXPECT_FALSE(isMarked); 85 EXPECT_FALSE(isMarked);
86 86
87 context->setTasksNeedSuspension(false); 87 context->setTasksNeedSuspension(false);
88 runner->resume(); 88 runner->resume();
89 blink::testing::runPendingTasks(); 89 blink::testing::runPendingTasks();
90 EXPECT_TRUE(isMarked); 90 EXPECT_TRUE(isMarked);
91 } 91 }
92 92
93 TEST(MainThreadTaskRunnerTest, RemoveRunner) 93 TEST(MainThreadTaskRunnerTest, RemoveRunner)
94 { 94 {
95 RefPtrWillBeRawPtr<NullExecutionContext> context = adoptRefWillBeNoop(new Nu llExecutionContext()); 95 RefPtrWillBeRawPtr<NullExecutionContext> context = adoptRefWillBeNoop(new Nu llExecutionContext());
96 OwnPtr<MainThreadTaskRunner> runner = MainThreadTaskRunner::create(context.g et()); 96 OwnPtrWillBeRawPtr<MainThreadTaskRunner> runner = MainThreadTaskRunner::crea te(context.get());
97 bool isMarked = false; 97 bool isMarked = false;
98 98
99 context->setTasksNeedSuspension(true); 99 context->setTasksNeedSuspension(true);
100 runner->postTask(FROM_HERE, MarkingBooleanTask::create(&isMarked)); 100 runner->postTask(FROM_HERE, MarkingBooleanTask::create(&isMarked));
101 runner.clear(); 101 runner.clear();
102 blink::testing::runPendingTasks(); 102 blink::testing::runPendingTasks();
103 EXPECT_FALSE(isMarked); 103 EXPECT_FALSE(isMarked);
104 } 104 }
105 105
106 } // namespace blink 106 } // namespace blink
OLDNEW
« Source/core/dom/MainThreadTaskRunner.cpp ('K') | « Source/core/dom/MainThreadTaskRunner.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698