OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/test/test_timeouts.h" |
8 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" |
9 #include "chrome/test/automation/browser_proxy.h" | 10 #include "chrome/test/automation/browser_proxy.h" |
10 #include "chrome/test/automation/tab_proxy.h" | 11 #include "chrome/test/automation/tab_proxy.h" |
11 #include "chrome/test/automation/window_proxy.h" | 12 #include "chrome/test/automation/window_proxy.h" |
12 #include "chrome/test/ui/ui_test.h" | 13 #include "chrome/test/ui/ui_test.h" |
13 #include "chrome/test/ui_test_utils.h" | 14 #include "chrome/test/ui_test_utils.h" |
14 #include "gfx/rect.h" | 15 #include "gfx/rect.h" |
15 #include "views/event.h" | 16 #include "views/event.h" |
16 | 17 |
17 namespace { | 18 namespace { |
(...skipping 16 matching lines...) Expand all Loading... |
34 | 35 |
35 TEST_F(HistoryTester, VerifyHistoryLength1) { | 36 TEST_F(HistoryTester, VerifyHistoryLength1) { |
36 // Test the history length for the following page transitions. | 37 // Test the history length for the following page transitions. |
37 // -open-> Page 1. | 38 // -open-> Page 1. |
38 | 39 |
39 const FilePath test_case_1( | 40 const FilePath test_case_1( |
40 FILE_PATH_LITERAL("history_length_test_page_1.html")); | 41 FILE_PATH_LITERAL("history_length_test_page_1.html")); |
41 GURL url_1 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_1); | 42 GURL url_1 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_1); |
42 NavigateToURL(url_1); | 43 NavigateToURL(url_1); |
43 WaitForFinish("History_Length_Test_1", "1", url_1, kTestCompleteCookie, | 44 WaitForFinish("History_Length_Test_1", "1", url_1, kTestCompleteCookie, |
44 kTestCompleteSuccess, action_max_timeout_ms()); | 45 kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms()); |
45 } | 46 } |
46 | 47 |
47 TEST_F(HistoryTester, VerifyHistoryLength2) { | 48 TEST_F(HistoryTester, VerifyHistoryLength2) { |
48 // Test the history length for the following page transitions. | 49 // Test the history length for the following page transitions. |
49 // -open-> Page 2 -redirect-> Page 3. | 50 // -open-> Page 2 -redirect-> Page 3. |
50 | 51 |
51 const FilePath test_case_2( | 52 const FilePath test_case_2( |
52 FILE_PATH_LITERAL("history_length_test_page_2.html")); | 53 FILE_PATH_LITERAL("history_length_test_page_2.html")); |
53 GURL url_2 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_2); | 54 GURL url_2 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_2); |
54 NavigateToURL(url_2); | 55 NavigateToURL(url_2); |
55 WaitForFinish("History_Length_Test_2", "1", url_2, kTestCompleteCookie, | 56 WaitForFinish("History_Length_Test_2", "1", url_2, kTestCompleteCookie, |
56 kTestCompleteSuccess, action_max_timeout_ms()); | 57 kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms()); |
57 } | 58 } |
58 | 59 |
59 TEST_F(HistoryTester, VerifyHistoryLength3) { | 60 TEST_F(HistoryTester, VerifyHistoryLength3) { |
60 // Test the history length for the following page transitions. | 61 // Test the history length for the following page transitions. |
61 // -open-> Page 1 -> open Page 2 -redirect Page 3. open Page 4 | 62 // -open-> Page 1 -> open Page 2 -redirect Page 3. open Page 4 |
62 // -navigate_backward-> Page 3 -navigate_backward->Page 1 | 63 // -navigate_backward-> Page 3 -navigate_backward->Page 1 |
63 // -navigate_forward-> Page 3 -navigate_forward-> Page 4 | 64 // -navigate_forward-> Page 3 -navigate_forward-> Page 4 |
64 const FilePath test_case_1( | 65 const FilePath test_case_1( |
65 FILE_PATH_LITERAL("history_length_test_page_1.html")); | 66 FILE_PATH_LITERAL("history_length_test_page_1.html")); |
66 GURL url_1 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_1); | 67 GURL url_1 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_1); |
67 NavigateToURL(url_1); | 68 NavigateToURL(url_1); |
68 WaitForFinish("History_Length_Test_1", "1", url_1, kTestCompleteCookie, | 69 WaitForFinish("History_Length_Test_1", "1", url_1, kTestCompleteCookie, |
69 kTestCompleteSuccess, action_max_timeout_ms()); | 70 kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms()); |
70 | 71 |
71 const FilePath test_case_2( | 72 const FilePath test_case_2( |
72 FILE_PATH_LITERAL("history_length_test_page_2.html")); | 73 FILE_PATH_LITERAL("history_length_test_page_2.html")); |
73 GURL url_2 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_2); | 74 GURL url_2 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_2); |
74 NavigateToURL(url_2); | 75 NavigateToURL(url_2); |
75 WaitForFinish("History_Length_Test_2", "1", url_2, kTestCompleteCookie, | 76 WaitForFinish("History_Length_Test_2", "1", url_2, kTestCompleteCookie, |
76 kTestCompleteSuccess, action_max_timeout_ms()); | 77 kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms()); |
77 | 78 |
78 const FilePath test_case_3( | 79 const FilePath test_case_3( |
79 FILE_PATH_LITERAL("history_length_test_page_4.html")); | 80 FILE_PATH_LITERAL("history_length_test_page_4.html")); |
80 GURL url_3 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_3); | 81 GURL url_3 = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case_3); |
81 NavigateToURL(url_3); | 82 NavigateToURL(url_3); |
82 WaitForFinish("History_Length_Test_3", "1", url_3, kTestCompleteCookie, | 83 WaitForFinish("History_Length_Test_3", "1", url_3, kTestCompleteCookie, |
83 kTestCompleteSuccess, action_max_timeout_ms()); | 84 kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms()); |
84 } | 85 } |
85 | 86 |
86 #if defined(OS_WIN) || defined(OS_LINUX) | 87 #if defined(OS_WIN) || defined(OS_LINUX) |
87 TEST_F(HistoryTester, ConsiderRedirectAfterGestureAsUserInitiated) { | 88 TEST_F(HistoryTester, ConsiderRedirectAfterGestureAsUserInitiated) { |
88 // Test the history length for the following page transition. | 89 // Test the history length for the following page transition. |
89 // | 90 // |
90 // -open-> Page 11 -slow_redirect-> Page 12. | 91 // -open-> Page 11 -slow_redirect-> Page 12. |
91 // | 92 // |
92 // If redirect occurs after a user gesture, e.g., mouse click, the | 93 // If redirect occurs after a user gesture, e.g., mouse click, the |
93 // redirect is more likely to be user-initiated rather than automatic. | 94 // redirect is more likely to be user-initiated rather than automatic. |
94 // Therefore, Page 11 should be in the history in addition to Page 12. | 95 // Therefore, Page 11 should be in the history in addition to Page 12. |
95 | 96 |
96 const FilePath test_case( | 97 const FilePath test_case( |
97 FILE_PATH_LITERAL("history_length_test_page_11.html")); | 98 FILE_PATH_LITERAL("history_length_test_page_11.html")); |
98 GURL url = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case); | 99 GURL url = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case); |
99 NavigateToURL(url); | 100 NavigateToURL(url); |
100 WaitForFinish("History_Length_Test_11", "1", url, kTestCompleteCookie, | 101 WaitForFinish("History_Length_Test_11", "1", url, kTestCompleteCookie, |
101 kTestCompleteSuccess, action_max_timeout_ms()); | 102 kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms()); |
102 | 103 |
103 // Simulate click. This only works for Windows. | 104 // Simulate click. This only works for Windows. |
104 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); | 105 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); |
105 ASSERT_TRUE(browser.get()); | 106 ASSERT_TRUE(browser.get()); |
106 scoped_refptr<WindowProxy> window = browser->GetWindow(); | 107 scoped_refptr<WindowProxy> window = browser->GetWindow(); |
107 ASSERT_TRUE(window.get()); | 108 ASSERT_TRUE(window.get()); |
108 gfx::Rect tab_view_bounds; | 109 gfx::Rect tab_view_bounds; |
109 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds, | 110 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds, |
110 true)); | 111 true)); |
111 ASSERT_TRUE( | 112 ASSERT_TRUE( |
112 window->SimulateOSClick(tab_view_bounds.CenterPoint(), | 113 window->SimulateOSClick(tab_view_bounds.CenterPoint(), |
113 views::Event::EF_LEFT_BUTTON_DOWN)); | 114 views::Event::EF_LEFT_BUTTON_DOWN)); |
114 | 115 |
115 NavigateToURL(GURL("javascript:redirectToPage12()")); | 116 NavigateToURL(GURL("javascript:redirectToPage12()")); |
116 WaitForFinish("History_Length_Test_12", "1", url, kTestCompleteCookie, | 117 WaitForFinish("History_Length_Test_12", "1", url, kTestCompleteCookie, |
117 kTestCompleteSuccess, action_max_timeout_ms()); | 118 kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms()); |
118 } | 119 } |
119 #endif // defined(OS_WIN) || defined(OS_LINUX) | 120 #endif // defined(OS_WIN) || defined(OS_LINUX) |
120 | 121 |
121 TEST_F(HistoryTester, ConsiderSlowRedirectAsUserInitiated) { | 122 TEST_F(HistoryTester, ConsiderSlowRedirectAsUserInitiated) { |
122 // Test the history length for the following page transition. | 123 // Test the history length for the following page transition. |
123 // | 124 // |
124 // -open-> Page 21 -redirect-> Page 22. | 125 // -open-> Page 21 -redirect-> Page 22. |
125 // | 126 // |
126 // If redirect occurs more than 5 seconds later after the page is loaded, | 127 // If redirect occurs more than 5 seconds later after the page is loaded, |
127 // the redirect is likely to be user-initiated. | 128 // the redirect is likely to be user-initiated. |
128 // Therefore, Page 21 should be in the history in addition to Page 22. | 129 // Therefore, Page 21 should be in the history in addition to Page 22. |
129 | 130 |
130 const FilePath test_case( | 131 const FilePath test_case( |
131 FILE_PATH_LITERAL("history_length_test_page_21.html")); | 132 FILE_PATH_LITERAL("history_length_test_page_21.html")); |
132 GURL url = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case); | 133 GURL url = ui_test_utils::GetTestUrl(FilePath(kHistoryDir), test_case); |
133 NavigateToURL(url); | 134 NavigateToURL(url); |
134 WaitForFinish("History_Length_Test_21", "1", url, kTestCompleteCookie, | 135 WaitForFinish("History_Length_Test_21", "1", url, kTestCompleteCookie, |
135 kTestCompleteSuccess, action_max_timeout_ms()); | 136 kTestCompleteSuccess, TestTimeouts::action_max_timeout_ms()); |
136 } | 137 } |
OLD | NEW |