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

Unified Diff: base/message_loop_unittest.cc

Issue 351029: Support dragging a virtual file out of the browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 12 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 | « base/file_util_win.cc ('k') | base/message_pump_win.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 35459)
+++ base/message_loop_unittest.cc (working copy)
@@ -1107,7 +1107,12 @@
virtual bool Dispatch(const MSG& msg) {
::TranslateMessage(&msg);
::DispatchMessage(&msg);
- return (++dispatch_count_ != 2);
+ // Do not count WM_TIMER since it is not what we post and it will cause
+ // flakiness.
+ if (msg.message != WM_TIMER)
+ ++dispatch_count_;
+ // We treat WM_LBUTTONUP as the last message.
+ return msg.message != WM_LBUTTONUP;
}
int dispatch_count_;
@@ -1130,6 +1135,37 @@
ASSERT_EQ(2, dispatcher.dispatch_count_);
}
+LRESULT CALLBACK MsgFilterProc(int code, WPARAM wparam, LPARAM lparam) {
+ if (code == base::MessagePumpForUI::kMessageFilterCode) {
+ MSG* msg = reinterpret_cast<MSG*>(lparam);
+ if (msg->message == WM_LBUTTONDOWN)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void RunTest_DispatcherWithMessageHook(MessageLoop::Type message_loop_type) {
+ MessageLoop loop(message_loop_type);
+
+ class MyTask : public Task {
+ public:
+ virtual void Run() {
+ PostMessage(NULL, WM_LBUTTONDOWN, 0, 0);
+ PostMessage(NULL, WM_LBUTTONUP, 'A', 0);
+ }
+ };
+ Task* task = new MyTask();
+ MessageLoop::current()->PostDelayedTask(FROM_HERE, task, 100);
+ HHOOK msg_hook = SetWindowsHookEx(WH_MSGFILTER,
+ MsgFilterProc,
+ NULL,
+ GetCurrentThreadId());
+ DispatcherImpl dispatcher;
+ MessageLoopForUI::current()->Run(&dispatcher);
+ ASSERT_EQ(1, dispatcher.dispatch_count_);
+ UnhookWindowsHookEx(msg_hook);
+}
+
class TestIOHandler : public MessageLoopForIO::IOHandler {
public:
TestIOHandler(const wchar_t* name, HANDLE signal, bool wait);
@@ -1423,6 +1459,11 @@
RunTest_Dispatcher(MessageLoop::TYPE_UI);
}
+TEST(MessageLoopTest, DispatcherWithMessageHook) {
+ // This test requires a UI loop
+ RunTest_DispatcherWithMessageHook(MessageLoop::TYPE_UI);
+}
+
TEST(MessageLoopTest, IOHandler) {
RunTest_IOHandler();
}
« no previous file with comments | « base/file_util_win.cc ('k') | base/message_pump_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698