summaryrefslogtreecommitdiffstats
path: root/base/message_loop_unittest.cc
diff options
context:
space:
mode:
authordarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-19 18:36:23 +0000
committerdarin@google.com <darin@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-19 18:36:23 +0000
commitb16ef312cb28582a1d324d20e4328afeef2c7538 (patch)
treebcbc40bbe3950501c888eab655f5070619ad1ac7 /base/message_loop_unittest.cc
parent4880adb3346faa91feea9d8ecfecc4ef499bf7fc (diff)
downloadchromium_src-b16ef312cb28582a1d324d20e4328afeef2c7538.zip
chromium_src-b16ef312cb28582a1d324d20e4328afeef2c7538.tar.gz
chromium_src-b16ef312cb28582a1d324d20e4328afeef2c7538.tar.bz2
Define MessagePumpDefault and use it to implement MessageLoop on non-Windows
platforms. This is actually just a first-step toward the real fix which is to use MessagePumpDefault on all platforms on non-UI and non-IO threads. This CL also fixes some GCC compilation errors. I renamed MessageLoopOwnable to TaskBase, which seems more appropriate since a MessageLoopOwnable has a next Task pointer and clearly is only meaningful in the context of Task. (I wonder why it is even a separate class, but that is another issue.) I had to make the next_task / set_next_task methods public since they are used by an inner class of MessageLoop. Perhaps those inner classes should be made into top-level classes, but that seemed like too much to change at this time. R=jar,mmentovai git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1045 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/message_loop_unittest.cc')
-rw-r--r--base/message_loop_unittest.cc36
1 files changed, 27 insertions, 9 deletions
diff --git a/base/message_loop_unittest.cc b/base/message_loop_unittest.cc
index fdd36ea..4cc003a 100644
--- a/base/message_loop_unittest.cc
+++ b/base/message_loop_unittest.cc
@@ -29,15 +29,25 @@
#include "base/logging.h"
#include "base/message_loop.h"
-#include "base/scoped_handle.h"
-#include "base/thread.h"
+#include "base/platform_thread.h"
#include "base/ref_counted.h"
+#include "base/thread.h"
#include "testing/gtest/include/gtest/gtest.h"
#if defined(OS_WIN)
#include "base/message_pump_win.h"
+#include "base/scoped_handle.h"
#endif
+//
+// TODO(darin): This file needs to be re-organized into acceptance tests that
+// apply to a MessageLoop configured to use any MessagePump. Then, those tests
+// need to be run against all MessagePump types supported by a platform.
+//
+// Finally, platform-specific MessageLoop tests should be grouped together to
+// avoid the chopping this file up with so many #ifdefs.
+//
+
namespace {
class MessageLoopTest : public testing::Test {
@@ -184,6 +194,8 @@ class NestingTest : public Task {
int* depth_;
};
+#if defined(OS_WIN)
+
LONG WINAPI BadExceptionHandler(EXCEPTION_POINTERS *ex_info) {
ADD_FAILURE() << "bad exception handler";
::ExitProcess(ex_info->ExceptionRecord->ExceptionCode);
@@ -200,7 +212,7 @@ class CrasherTask : public Task {
: trash_SEH_handler_(trash_SEH_handler) {
}
void Run() {
- Sleep(1);
+ PlatformThread::Sleep(1);
if (trash_SEH_handler_)
::SetUnhandledExceptionFilter(&BadExceptionHandler);
// Generate a SEH fault. We do it in asm to make sure we know how to undo
@@ -217,8 +229,8 @@ class CrasherTask : public Task {
bad_array_[0] = 66;
-#elif
-
+#else
+#error "needs architecture support"
#endif
MessageLoop::current()->Quit();
@@ -259,6 +271,8 @@ LONG WINAPI HandleCrasherTaskException(EXCEPTION_POINTERS *ex_info) {
return EXCEPTION_CONTINUE_EXECUTION;
}
+#endif // defined(OS_WIN)
+
} // namespace
@@ -406,6 +420,8 @@ class OrderedTasks : public Task {
int cookie_;
};
+#if defined(OS_WIN)
+
// MessageLoop implicitly start a "modal message loop". Modal dialog boxes,
// common controls (like OpenFile) and StartDoc printing function can cause
// implicit message loops.
@@ -447,6 +463,8 @@ class EndDialogTask : public OrderedTasks {
}
};
+#endif // defined(OS_WIN)
+
class RecursiveTask : public OrderedTasks {
public:
RecursiveTask(int depth, TaskList* order, int cookie, bool is_reentrant)
@@ -563,7 +581,7 @@ TEST(MessageLoop, RecursiveDenial1) {
MessageLoop::current()->Run();
// FIFO order.
- ASSERT_EQ(order.size(), 14);
+ ASSERT_EQ(14U, 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));
@@ -593,7 +611,7 @@ TEST(MessageLoop, RecursiveSupport1) {
MessageLoop::current()->Run();
// FIFO order.
- ASSERT_EQ(order.size(), 14);
+ ASSERT_EQ(14U, 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));
@@ -728,7 +746,7 @@ TEST(MessageLoop, NonNestableWithNoNesting) {
MessageLoop::current()->Run();
// FIFO order.
- ASSERT_EQ(order.size(), 6);
+ ASSERT_EQ(6U, order.size());
EXPECT_EQ(order[ 0], TaskItem(ORDERERD, 1, true));
EXPECT_EQ(order[ 1], TaskItem(ORDERERD, 1, false));
EXPECT_EQ(order[ 2], TaskItem(ORDERERD, 2, true));
@@ -756,7 +774,7 @@ TEST(MessageLoop, NonNestableInNestedLoop) {
MessageLoop::current()->Run();
// FIFO order.
- ASSERT_EQ(order.size(), 10);
+ ASSERT_EQ(10U, order.size());
EXPECT_EQ(order[ 0], TaskItem(PUMPS, 1, true));
EXPECT_EQ(order[ 1], TaskItem(ORDERERD, 3, true));
EXPECT_EQ(order[ 2], TaskItem(ORDERERD, 3, false));