| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 24 #include "base/threading/platform_thread.h" | 24 #include "base/threading/platform_thread.h" |
| 25 #include "base/threading/thread.h" | 25 #include "base/threading/thread.h" |
| 26 #include "build/build_config.h" | 26 #include "build/build_config.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 28 |
| 29 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
| 30 #include "base/message_loop/message_pump_win.h" | 30 #include "base/message_loop/message_pump_win.h" |
| 31 #include "base/process/memory.h" | 31 #include "base/process/memory.h" |
| 32 #include "base/strings/string16.h" | 32 #include "base/strings/string16.h" |
| 33 #include "base/win/current_module.h" |
| 33 #include "base/win/scoped_handle.h" | 34 #include "base/win/scoped_handle.h" |
| 34 #endif | 35 #endif |
| 35 | 36 |
| 36 namespace base { | 37 namespace base { |
| 37 | 38 |
| 38 // TODO(darin): Platform-specific MessageLoop tests should be grouped together | 39 // TODO(darin): Platform-specific MessageLoop tests should be grouped together |
| 39 // to avoid chopping this file up with so many #ifdefs. | 40 // to avoid chopping this file up with so many #ifdefs. |
| 40 | 41 |
| 41 namespace { | 42 namespace { |
| 42 | 43 |
| (...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 } | 917 } |
| 917 EXPECT_TRUE(did_run); | 918 EXPECT_TRUE(did_run); |
| 918 MessageLoop::current()->QuitWhenIdle(); | 919 MessageLoop::current()->QuitWhenIdle(); |
| 919 break; | 920 break; |
| 920 } | 921 } |
| 921 return 0; | 922 return 0; |
| 922 } | 923 } |
| 923 | 924 |
| 924 TEST(MessageLoopTest, AlwaysHaveUserMessageWhenNesting) { | 925 TEST(MessageLoopTest, AlwaysHaveUserMessageWhenNesting) { |
| 925 MessageLoop loop(MessageLoop::TYPE_UI); | 926 MessageLoop loop(MessageLoop::TYPE_UI); |
| 926 HINSTANCE instance = GetModuleFromAddress(&TestWndProcThunk); | 927 HINSTANCE instance = CURRENT_MODULE(); |
| 927 WNDCLASSEX wc = {0}; | 928 WNDCLASSEX wc = {0}; |
| 928 wc.cbSize = sizeof(wc); | 929 wc.cbSize = sizeof(wc); |
| 929 wc.lpfnWndProc = TestWndProcThunk; | 930 wc.lpfnWndProc = TestWndProcThunk; |
| 930 wc.hInstance = instance; | 931 wc.hInstance = instance; |
| 931 wc.lpszClassName = L"MessageLoopTest_HWND"; | 932 wc.lpszClassName = L"MessageLoopTest_HWND"; |
| 932 ATOM atom = RegisterClassEx(&wc); | 933 ATOM atom = RegisterClassEx(&wc); |
| 933 ASSERT_TRUE(atom); | 934 ASSERT_TRUE(atom); |
| 934 | 935 |
| 935 HWND message_hwnd = CreateWindow(MAKEINTATOM(atom), 0, 0, 0, 0, 0, 0, | 936 HWND message_hwnd = CreateWindow(MAKEINTATOM(atom), 0, 0, 0, 0, 0, 0, |
| 936 HWND_MESSAGE, 0, instance, 0); | 937 HWND_MESSAGE, 0, instance, 0); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 // already has another active loop. This happens when thread creation fails. | 972 // already has another active loop. This happens when thread creation fails. |
| 972 MessageLoop loop; | 973 MessageLoop loop; |
| 973 scoped_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound( | 974 scoped_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound( |
| 974 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback())); | 975 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback())); |
| 975 unbound_loop.reset(); | 976 unbound_loop.reset(); |
| 976 EXPECT_EQ(&loop, MessageLoop::current()); | 977 EXPECT_EQ(&loop, MessageLoop::current()); |
| 977 EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get()); | 978 EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get()); |
| 978 } | 979 } |
| 979 | 980 |
| 980 } // namespace base | 981 } // namespace base |
| OLD | NEW |