| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome_frame/test/chrome_frame_automation_mock.h" | 5 #include "chrome_frame/test/chrome_frame_automation_mock.h" |
| 6 #include "chrome_frame/test/chrome_frame_test_utils.h" | 6 #include "chrome_frame/test/chrome_frame_test_utils.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 const int kLongWaitTimeout = 25 * 1000; | 9 const base::TimeDelta kLongWaitTimeout = base::TimeDelta::FromSeconds(25); |
| 10 | 10 |
| 11 TEST(ChromeFrame, Launch) { | 11 TEST(ChromeFrame, Launch) { |
| 12 MessageLoopForUI loop; | 12 MessageLoopForUI loop; |
| 13 AutomationMockLaunch mock_launch(&loop, kLongWaitTimeout); | 13 AutomationMockLaunch mock_launch(&loop, |
| 14 kLongWaitTimeout.InMilliseconds()); |
| 14 | 15 |
| 15 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); | 16 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); |
| 16 | 17 |
| 17 mock_launch.Navigate("about:blank"); | 18 mock_launch.Navigate("about:blank"); |
| 18 loop.RunWithDispatcher(NULL); | 19 loop.RunWithDispatcher(NULL); |
| 19 EXPECT_TRUE(mock_launch.launch_result()); | 20 EXPECT_TRUE(mock_launch.launch_result()); |
| 20 } | 21 } |
| 21 | 22 |
| 22 TEST(ChromeFrame, Navigate) { | 23 TEST(ChromeFrame, Navigate) { |
| 23 MessageLoopForUI loop; | 24 MessageLoopForUI loop; |
| 24 AutomationMockNavigate mock_navigate(&loop, kLongWaitTimeout); | 25 AutomationMockNavigate mock_navigate(&loop, |
| 26 kLongWaitTimeout.InMilliseconds()); |
| 25 | 27 |
| 26 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); | 28 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); |
| 27 | 29 |
| 28 mock_navigate.NavigateRelativeFile(L"postmessage_basic_frame.html"); | 30 mock_navigate.NavigateRelativeFile(L"postmessage_basic_frame.html"); |
| 29 loop.RunWithDispatcher(NULL); | 31 loop.RunWithDispatcher(NULL); |
| 30 EXPECT_FALSE(mock_navigate.navigation_result()); | 32 EXPECT_FALSE(mock_navigate.navigation_result()); |
| 31 } | 33 } |
| 32 | 34 |
| 33 TEST(ChromeFrame, PostMessage) { | 35 TEST(ChromeFrame, PostMessage) { |
| 34 MessageLoopForUI loop; | 36 MessageLoopForUI loop; |
| 35 AutomationMockPostMessage mock_postmessage(&loop, kLongWaitTimeout); | 37 AutomationMockPostMessage mock_postmessage(&loop, |
| 38 kLongWaitTimeout.InMilliseconds()); |
| 36 | 39 |
| 37 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); | 40 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); |
| 38 | 41 |
| 39 mock_postmessage.NavigateRelativeFile(L"postmessage_basic_frame.html"); | 42 mock_postmessage.NavigateRelativeFile(L"postmessage_basic_frame.html"); |
| 40 loop.RunWithDispatcher(NULL); | 43 loop.RunWithDispatcher(NULL); |
| 41 EXPECT_FALSE(mock_postmessage.postmessage_result()); | 44 EXPECT_FALSE(mock_postmessage.postmessage_result()); |
| 42 } | 45 } |
| 43 | 46 |
| 44 TEST(ChromeFrame, RequestStart) { | 47 TEST(ChromeFrame, RequestStart) { |
| 45 MessageLoopForUI loop; | 48 MessageLoopForUI loop; |
| 46 AutomationMockHostNetworkRequestStart mock_request_start(&loop, | 49 AutomationMockHostNetworkRequestStart mock_request_start( |
| 47 kLongWaitTimeout); | 50 &loop, kLongWaitTimeout.InMilliseconds()); |
| 48 | 51 |
| 49 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); | 52 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); |
| 50 | 53 |
| 51 mock_request_start.NavigateRelative(L"postmessage_basic_frame.html"); | 54 mock_request_start.NavigateRelative(L"postmessage_basic_frame.html"); |
| 52 loop.RunWithDispatcher(NULL); | 55 loop.RunWithDispatcher(NULL); |
| 53 EXPECT_TRUE(mock_request_start.request_start_result()); | 56 EXPECT_TRUE(mock_request_start.request_start_result()); |
| 54 } | 57 } |
| 55 | 58 |
| OLD | NEW |