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 3// found in the LICENSE file. 4 5#include "chrome_frame/test/chrome_frame_automation_mock.h" 6#include "chrome_frame/test/chrome_frame_test_utils.h" 7#include "testing/gtest/include/gtest/gtest.h" 8 9const base::TimeDelta kLongWaitTimeout = base::TimeDelta::FromSeconds(25); 10 11TEST(ChromeFrame, Launch) { 12 base::MessageLoopForUI loop; 13 AutomationMockLaunch mock_launch(&loop, 14 kLongWaitTimeout.InMilliseconds()); 15 16 loop.PostDelayedTask( 17 FROM_HERE, base::MessageLoop::QuitClosure(), kLongWaitTimeout); 18 19 mock_launch.Navigate("about:blank"); 20 base::RunLoop run_loop(NULL); 21 run_loop.Run(); 22 EXPECT_TRUE(mock_launch.launch_result()); 23} 24 25TEST(ChromeFrame, Navigate) { 26 base::MessageLoopForUI loop; 27 AutomationMockNavigate mock_navigate(&loop, 28 kLongWaitTimeout.InMilliseconds()); 29 30 loop.PostDelayedTask( 31 FROM_HERE, base::MessageLoop::QuitClosure(), kLongWaitTimeout); 32 33 mock_navigate.NavigateRelativeFile(L"postmessage_basic_frame.html"); 34 base::RunLoop run_loop(NULL); 35 run_loop.Run(); 36 EXPECT_FALSE(mock_navigate.navigation_result()); 37} 38 39TEST(ChromeFrame, PostMessage) { 40 base::MessageLoopForUI loop; 41 AutomationMockPostMessage mock_postmessage(&loop, 42 kLongWaitTimeout.InMilliseconds()); 43 44 loop.PostDelayedTask( 45 FROM_HERE, base::MessageLoop::QuitClosure(), kLongWaitTimeout); 46 47 mock_postmessage.NavigateRelativeFile(L"postmessage_basic_frame.html"); 48 base::RunLoop run_loop(NULL); 49 run_loop.Run(); 50 EXPECT_FALSE(mock_postmessage.postmessage_result()); 51} 52 53TEST(ChromeFrame, RequestStart) { 54 base::MessageLoopForUI loop; 55 AutomationMockHostNetworkRequestStart mock_request_start( 56 &loop, kLongWaitTimeout.InMilliseconds()); 57 58 loop.PostDelayedTask( 59 FROM_HERE, base::MessageLoop::QuitClosure(), kLongWaitTimeout); 60 61 mock_request_start.NavigateRelative(L"postmessage_basic_frame.html"); 62 base::RunLoop run_loop(NULL); 63 run_loop.Run(); 64 EXPECT_TRUE(mock_request_start.request_start_result()); 65} 66 67