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

Unified Diff: base/message_loop_unittest.cc

Issue 6507017: MessagePump implementations should call DoWork and DoDelayedWork at equal priority (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/message_pump.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop_unittest.cc
===================================================================
--- base/message_loop_unittest.cc (revision 75181)
+++ base/message_loop_unittest.cc (working copy)
@@ -768,6 +768,18 @@
bool is_reentrant_;
};
+class RecursiveSlowTask : public RecursiveTask {
+ public:
+ RecursiveSlowTask(int depth, TaskList* order, int cookie, bool is_reentrant)
+ : RecursiveTask(depth, order, cookie, is_reentrant) {
+ }
+
+ virtual void Run() {
+ RecursiveTask::Run();
+ PlatformThread::Sleep(10); // milliseconds
+ }
+};
+
class QuitTask : public OrderedTasks {
public:
QuitTask(TaskList* order, int cookie)
@@ -893,6 +905,42 @@
EXPECT_EQ(order[13], TaskItem(RECURSIVE, 2, false));
}
+void RunTest_RecursiveDenial3(MessageLoop::Type message_loop_type) {
+ MessageLoop loop(message_loop_type);
+
+ EXPECT_TRUE(MessageLoop::current()->NestableTasksAllowed());
+ TaskList order;
+ MessageLoop::current()->PostTask(FROM_HERE,
+ new RecursiveSlowTask(2, &order, 1, false));
+ MessageLoop::current()->PostTask(FROM_HERE,
+ new RecursiveSlowTask(2, &order, 2, false));
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ new OrderedTasks(&order, 3), 5);
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ new QuitTask(&order, 4), 5);
+
+ MessageLoop::current()->Run();
+
+ // FIFO order.
+ ASSERT_EQ(16U, order.size());
+ EXPECT_EQ(order[ 0], TaskItem(RECURSIVE, 1, true));
+ EXPECT_EQ(order[ 1], TaskItem(RECURSIVE, 1, false));
+ EXPECT_EQ(order[ 2], TaskItem(RECURSIVE, 2, true));
+ EXPECT_EQ(order[ 3], TaskItem(RECURSIVE, 2, false));
+ EXPECT_EQ(order[ 4], TaskItem(RECURSIVE, 1, true));
+ EXPECT_EQ(order[ 5], TaskItem(RECURSIVE, 1, false));
+ EXPECT_EQ(order[ 6], TaskItem(ORDERERD, 3, true));
+ EXPECT_EQ(order[ 7], TaskItem(ORDERERD, 3, false));
+ EXPECT_EQ(order[ 8], TaskItem(RECURSIVE, 2, true));
+ EXPECT_EQ(order[ 9], TaskItem(RECURSIVE, 2, false));
+ EXPECT_EQ(order[10], TaskItem(QUITMESSAGELOOP, 4, true));
+ EXPECT_EQ(order[11], TaskItem(QUITMESSAGELOOP, 4, false));
+ EXPECT_EQ(order[12], TaskItem(RECURSIVE, 1, true));
+ EXPECT_EQ(order[13], TaskItem(RECURSIVE, 1, false));
+ EXPECT_EQ(order[14], TaskItem(RECURSIVE, 2, true));
+ EXPECT_EQ(order[15], TaskItem(RECURSIVE, 2, false));
+}
+
void RunTest_RecursiveSupport1(MessageLoop::Type message_loop_type) {
MessageLoop loop(message_loop_type);
@@ -1426,6 +1474,12 @@
RunTest_RecursiveDenial1(MessageLoop::TYPE_IO);
}
+TEST(MessageLoopTest, RecursiveDenial3) {
+ RunTest_RecursiveDenial3(MessageLoop::TYPE_DEFAULT);
+ RunTest_RecursiveDenial3(MessageLoop::TYPE_UI);
+ RunTest_RecursiveDenial3(MessageLoop::TYPE_IO);
+}
+
TEST(MessageLoopTest, RecursiveSupport1) {
RunTest_RecursiveSupport1(MessageLoop::TYPE_DEFAULT);
RunTest_RecursiveSupport1(MessageLoop::TYPE_UI);
« no previous file with comments | « no previous file | base/message_pump.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698