OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // History UI tests | 5 // History UI tests |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "chrome/browser/view_ids.h" | 8 #include "chrome/browser/view_ids.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/test/automation/browser_proxy.h" | 10 #include "chrome/test/automation/browser_proxy.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 virtual void SetUp() { | 26 virtual void SetUp() { |
27 show_window_ = true; | 27 show_window_ = true; |
28 UITest::SetUp(); | 28 UITest::SetUp(); |
29 } | 29 } |
30 }; | 30 }; |
31 | 31 |
32 // TODO(yuzo): Fix the following flaky (hence disabled) tests. | 32 // TODO(yuzo): Fix the following flaky (hence disabled) tests. |
33 // These tests are flaky because automatic and user-initiated transitions are | 33 // These tests are flaky because automatic and user-initiated transitions are |
34 // distinguished based on the interval between page load and redirect. | 34 // distinguished based on the interval between page load and redirect. |
35 | 35 |
36 TEST_F(HistoryTester, DISABLED_VerifyHistoryLength) { | 36 // Flaky, http://crbug.com/39785. |
| 37 TEST_F(HistoryTester, FLAKY_VerifyHistoryLength1) { |
37 // Test the history length for the following page transitions. | 38 // Test the history length for the following page transitions. |
38 // | |
39 // Test case 1: | |
40 // -open-> Page 1. | 39 // -open-> Page 1. |
41 // Test case 2: | |
42 // -open-> Page 2 -redirect-> Page 3. | |
43 // Test case 3: | |
44 // -open-> Page 4 -navigate_backward-> Page 3 -navigate_backward->Page 1 | |
45 // -navigate_forward-> Page 3 -navigate_forward-> Page 4 | |
46 // | |
47 // Note that Page 2 is not visited on navigating backward/forward. | |
48 | 40 |
49 // Test case 1 | |
50 std::wstring test_case_1 = L"history_length_test_page_1.html"; | 41 std::wstring test_case_1 = L"history_length_test_page_1.html"; |
51 GURL url_1 = GetTestUrl(L"History", test_case_1); | 42 GURL url_1 = GetTestUrl(L"History", test_case_1); |
52 NavigateToURL(url_1); | 43 NavigateToURL(url_1); |
53 WaitForFinish("History_Length_Test_1", "1", url_1, kTestCompleteCookie, | 44 WaitForFinish("History_Length_Test_1", "1", url_1, kTestCompleteCookie, |
54 kTestCompleteSuccess, action_max_timeout_ms()); | 45 kTestCompleteSuccess, action_max_timeout_ms()); |
| 46 } |
55 | 47 |
56 // Test case 2 | 48 // Disabled, http://crbug.com/39785. |
| 49 TEST_F(HistoryTester, DISABLED_VerifyHistoryLength2) { |
| 50 // Test the history length for the following page transitions. |
| 51 // -open-> Page 2 -redirect-> Page 3. |
| 52 |
57 std::wstring test_case_2 = L"history_length_test_page_2.html"; | 53 std::wstring test_case_2 = L"history_length_test_page_2.html"; |
58 GURL url_2 = GetTestUrl(L"History", test_case_2); | 54 GURL url_2 = GetTestUrl(L"History", test_case_2); |
59 NavigateToURL(url_2); | 55 NavigateToURL(url_2); |
60 WaitForFinish("History_Length_Test_2", "1", url_2, kTestCompleteCookie, | 56 WaitForFinish("History_Length_Test_2", "1", url_2, kTestCompleteCookie, |
61 kTestCompleteSuccess, action_max_timeout_ms()); | 57 kTestCompleteSuccess, action_max_timeout_ms()); |
| 58 } |
62 | 59 |
63 // Test case 3 | 60 // Disabled, http://crbug.com/39785. |
| 61 TEST_F(HistoryTester, DISABLED_VerifyHistoryLength3) { |
| 62 // Test the history length for the following page transitions. |
| 63 // -open-> Page 4 -navigate_backward-> Page 3 -navigate_backward->Page 1 |
| 64 // -navigate_forward-> Page 3 -navigate_forward-> Page 4 |
| 65 |
64 std::wstring test_case_3 = L"history_length_test_page_4.html"; | 66 std::wstring test_case_3 = L"history_length_test_page_4.html"; |
65 GURL url_3 = GetTestUrl(L"History", test_case_3); | 67 GURL url_3 = GetTestUrl(L"History", test_case_3); |
66 NavigateToURL(url_3); | 68 NavigateToURL(url_3); |
67 WaitForFinish("History_Length_Test_3", "1", url_3, kTestCompleteCookie, | 69 WaitForFinish("History_Length_Test_3", "1", url_3, kTestCompleteCookie, |
68 kTestCompleteSuccess, action_max_timeout_ms()); | 70 kTestCompleteSuccess, action_max_timeout_ms()); |
69 } | 71 } |
70 | 72 |
71 #if defined(OS_WIN) || defined(OS_LINUX) | 73 #if defined(OS_WIN) || defined(OS_LINUX) |
72 TEST_F(HistoryTester, DISABLED_ConsiderRedirectAfterGestureAsUserInitiated) { | 74 // Flaky, http://crbug.com/39785. |
| 75 TEST_F(HistoryTester, FLAKY_ConsiderRedirectAfterGestureAsUserInitiated) { |
73 // Test the history length for the following page transition. | 76 // Test the history length for the following page transition. |
74 // | 77 // |
75 // -open-> Page 11 -slow_redirect-> Page 12. | 78 // -open-> Page 11 -slow_redirect-> Page 12. |
76 // | 79 // |
77 // If redirect occurs after a user gesture, e.g., mouse click, the | 80 // If redirect occurs after a user gesture, e.g., mouse click, the |
78 // redirect is more likely to be user-initiated rather than automatic. | 81 // redirect is more likely to be user-initiated rather than automatic. |
79 // Therefore, Page 11 should be in the history in addition to Page 12. | 82 // Therefore, Page 11 should be in the history in addition to Page 12. |
80 | 83 |
81 std::wstring test_case = L"history_length_test_page_11.html"; | 84 std::wstring test_case = L"history_length_test_page_11.html"; |
82 GURL url = GetTestUrl(L"History", test_case); | 85 GURL url = GetTestUrl(L"History", test_case); |
83 NavigateToURL(url); | 86 NavigateToURL(url); |
84 WaitForFinish("History_Length_Test_11", "1", url, kTestCompleteCookie, | 87 WaitForFinish("History_Length_Test_11", "1", url, kTestCompleteCookie, |
85 kTestCompleteSuccess, action_max_timeout_ms()); | 88 kTestCompleteSuccess, action_max_timeout_ms()); |
86 | 89 |
87 // Simulate click. This only works for Windows. | 90 // Simulate click. This only works for Windows. |
88 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); | 91 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); |
| 92 ASSERT_TRUE(browser.get()); |
89 scoped_refptr<WindowProxy> window = browser->GetWindow(); | 93 scoped_refptr<WindowProxy> window = browser->GetWindow(); |
| 94 ASSERT_TRUE(window.get()); |
90 gfx::Rect tab_view_bounds; | 95 gfx::Rect tab_view_bounds; |
91 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds, | 96 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds, |
92 true)); | 97 true)); |
93 ASSERT_TRUE( | 98 ASSERT_TRUE( |
94 window->SimulateOSClick(tab_view_bounds.CenterPoint(), | 99 window->SimulateOSClick(tab_view_bounds.CenterPoint(), |
95 views::Event::EF_LEFT_BUTTON_DOWN)); | 100 views::Event::EF_LEFT_BUTTON_DOWN)); |
96 | 101 |
97 NavigateToURL(GURL("javascript:redirectToPage12()")); | 102 NavigateToURL(GURL("javascript:redirectToPage12()")); |
98 WaitForFinish("History_Length_Test_12", "1", url, kTestCompleteCookie, | 103 WaitForFinish("History_Length_Test_12", "1", url, kTestCompleteCookie, |
99 kTestCompleteSuccess, action_max_timeout_ms()); | 104 kTestCompleteSuccess, action_max_timeout_ms()); |
100 } | 105 } |
101 #endif // defined(OS_WIN) || defined(OS_LINUX) | 106 #endif // defined(OS_WIN) || defined(OS_LINUX) |
102 | 107 |
103 TEST_F(HistoryTester, DISABLED_ConsiderSlowRedirectAsUserInitiated) { | 108 // Flaky, http://crbug.com/39785. |
| 109 TEST_F(HistoryTester, FLAKY_ConsiderSlowRedirectAsUserInitiated) { |
104 // Test the history length for the following page transition. | 110 // Test the history length for the following page transition. |
105 // | 111 // |
106 // -open-> Page 21 -redirect-> Page 22. | 112 // -open-> Page 21 -redirect-> Page 22. |
107 // | 113 // |
108 // If redirect occurs more than 5 seconds later after the page is loaded, | 114 // If redirect occurs more than 5 seconds later after the page is loaded, |
109 // the redirect is likely to be user-initiated. | 115 // the redirect is likely to be user-initiated. |
110 // Therefore, Page 21 should be in the history in addition to Page 22. | 116 // Therefore, Page 21 should be in the history in addition to Page 22. |
111 | 117 |
112 std::wstring test_case = L"history_length_test_page_21.html"; | 118 std::wstring test_case = L"history_length_test_page_21.html"; |
113 GURL url = GetTestUrl(L"History", test_case); | 119 GURL url = GetTestUrl(L"History", test_case); |
114 NavigateToURL(url); | 120 NavigateToURL(url); |
115 WaitForFinish("History_Length_Test_21", "1", url, kTestCompleteCookie, | 121 WaitForFinish("History_Length_Test_21", "1", url, kTestCompleteCookie, |
116 kTestCompleteSuccess, action_max_timeout_ms()); | 122 kTestCompleteSuccess, action_max_timeout_ms()); |
117 } | 123 } |
OLD | NEW |