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

Side by Side Diff: chrome_frame/test/chrome_frame_automation_mock.cc

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: phajdan feedback Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 base::TimeDelta kLongWaitTimeout = base::TimeDelta::FromSeconds(25); 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, 13 AutomationMockLaunch mock_launch(&loop,
14 kLongWaitTimeout.InMilliseconds()); 14 kLongWaitTimeout.InMilliseconds());
15 15
16 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); 16 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout);
17 17
18 mock_launch.Navigate("about:blank"); 18 mock_launch.Navigate("about:blank");
19 loop.RunWithDispatcher(NULL); 19 base::RunLoop run_loop(NULL);
20 run_loop.Run();
20 EXPECT_TRUE(mock_launch.launch_result()); 21 EXPECT_TRUE(mock_launch.launch_result());
21 } 22 }
22 23
23 TEST(ChromeFrame, Navigate) { 24 TEST(ChromeFrame, Navigate) {
24 MessageLoopForUI loop; 25 MessageLoopForUI loop;
25 AutomationMockNavigate mock_navigate(&loop, 26 AutomationMockNavigate mock_navigate(&loop,
26 kLongWaitTimeout.InMilliseconds()); 27 kLongWaitTimeout.InMilliseconds());
27 28
28 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); 29 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout);
29 30
30 mock_navigate.NavigateRelativeFile(L"postmessage_basic_frame.html"); 31 mock_navigate.NavigateRelativeFile(L"postmessage_basic_frame.html");
31 loop.RunWithDispatcher(NULL); 32 base::RunLoop run_loop(NULL);
33 run_loop.Run();
32 EXPECT_FALSE(mock_navigate.navigation_result()); 34 EXPECT_FALSE(mock_navigate.navigation_result());
33 } 35 }
34 36
35 TEST(ChromeFrame, PostMessage) { 37 TEST(ChromeFrame, PostMessage) {
36 MessageLoopForUI loop; 38 MessageLoopForUI loop;
37 AutomationMockPostMessage mock_postmessage(&loop, 39 AutomationMockPostMessage mock_postmessage(&loop,
38 kLongWaitTimeout.InMilliseconds()); 40 kLongWaitTimeout.InMilliseconds());
39 41
40 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); 42 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout);
41 43
42 mock_postmessage.NavigateRelativeFile(L"postmessage_basic_frame.html"); 44 mock_postmessage.NavigateRelativeFile(L"postmessage_basic_frame.html");
43 loop.RunWithDispatcher(NULL); 45 base::RunLoop run_loop(NULL);
46 run_loop.Run();
44 EXPECT_FALSE(mock_postmessage.postmessage_result()); 47 EXPECT_FALSE(mock_postmessage.postmessage_result());
45 } 48 }
46 49
47 TEST(ChromeFrame, RequestStart) { 50 TEST(ChromeFrame, RequestStart) {
48 MessageLoopForUI loop; 51 MessageLoopForUI loop;
49 AutomationMockHostNetworkRequestStart mock_request_start( 52 AutomationMockHostNetworkRequestStart mock_request_start(
50 &loop, kLongWaitTimeout.InMilliseconds()); 53 &loop, kLongWaitTimeout.InMilliseconds());
51 54
52 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout); 55 loop.PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), kLongWaitTimeout);
53 56
54 mock_request_start.NavigateRelative(L"postmessage_basic_frame.html"); 57 mock_request_start.NavigateRelative(L"postmessage_basic_frame.html");
55 loop.RunWithDispatcher(NULL); 58 base::RunLoop run_loop(NULL);
59 run_loop.Run();
56 EXPECT_TRUE(mock_request_start.request_start_result()); 60 EXPECT_TRUE(mock_request_start.request_start_result());
57 } 61 }
58 62
OLDNEW
« no previous file with comments | « chrome/test/perf/rendering/throughput_tests.cc ('k') | chrome_frame/test/chrome_frame_test_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698