OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/app/chrome_dll_resource.h" | 5 #include "chrome/app/chrome_dll_resource.h" |
6 #include "chrome/common/url_constants.h" | |
7 #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" | 6 #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" |
8 #include "chrome/test/automation/browser_proxy.h" | 7 #include "chrome/test/automation/browser_proxy.h" |
9 #include "chrome/test/automation/tab_proxy.h" | 8 #include "chrome/test/automation/tab_proxy.h" |
10 #include "chrome/test/ui/ui_test.h" | 9 #include "chrome/test/ui/ui_test.h" |
11 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
12 #include "net/base/net_util.h" | 11 #include "net/base/net_util.h" |
13 | 12 |
14 #if defined(OS_MACOSX) | 13 #if defined(OS_MACOSX) |
15 // The window pops up, but doesn't close. | 14 // The window pops up, but doesn't close. |
16 #define MAYBE_IncognitoWindow DISABLED_IncognitoWindow | 15 #define MAYBE_IncognitoWindow DISABLED_IncognitoWindow |
17 #define MAYBE_OpenCloseBrowserWindowWithAccelerator \ | 16 #define MAYBE_OpenCloseBrowserWindowWithAccelerator \ |
18 DISABLED_OpenCloseBrowserWindowWithAccelerator | 17 DISABLED_OpenCloseBrowserWindowWithAccelerator |
19 #else | 18 #else |
20 // http://code.google.com/p/chromium/issues/detail?id=14731 | 19 // http://code.google.com/p/chromium/issues/detail?id=14731 |
21 #define MAYBE_IncognitoWindow DISABLED_IncognitoWindow | 20 #define MAYBE_IncognitoWindow DISABLED_IncognitoWindow |
22 // http://crbug.com/19394 | 21 // http://crbug.com/19394 |
23 #define MAYBE_OpenCloseBrowserWindowWithAccelerator \ | 22 #define MAYBE_OpenCloseBrowserWindowWithAccelerator \ |
24 DISABLED_OpenCloseBrowserWindowWithAccelerator | 23 DISABLED_OpenCloseBrowserWindowWithAccelerator |
25 #endif | 24 #endif |
26 | 25 |
27 // http://code.google.com/p/chromium/issues/detail?id=14774 | 26 // http://code.google.com/p/chromium/issues/detail?id=14774 |
28 #if defined(OS_WIN) && !defined(NDEBUG) | 27 #if defined(OS_WIN) && !defined(NDEBUG) |
29 #define MAYBE_CloseTab DISABLED_CloseTab | 28 #define MAYBE_CloseTab DISABLED_CloseTab |
30 #define MAYBE_CloseBrowserWindow DISABLED_CloseBrowserWindow | 29 #define MAYBE_CloseBrowserWindow DISABLED_CloseBrowserWindow |
31 #else | 30 #else |
32 #define MAYBE_CloseTab CloseTab | 31 #define MAYBE_CloseTab CloseTab |
33 #define MAYBE_CloseBrowserWindow CloseBrowserWindow | 32 #define MAYBE_CloseBrowserWindow CloseBrowserWindow |
34 #endif | 33 #endif |
35 | 34 |
36 // TODO(phajdan.jr): Enable FindInPageTest on Mac. | |
37 #if !defined(OS_MACOSX) | |
38 TEST_F(AutomatedUITestBase, FindInPage) { | |
39 ASSERT_TRUE(FindInPage()); | |
40 bool is_visible; | |
41 ASSERT_TRUE(active_browser()->IsFindWindowFullyVisible(&is_visible)); | |
42 EXPECT_TRUE(is_visible); | |
43 } | |
44 #endif // !defined(OS_MACOSX) | |
45 | |
46 TEST_F(AutomatedUITestBase, Home) { | |
47 FilePath path_prefix(test_data_directory_.AppendASCII("session_history")); | |
48 GURL bot1(net::FilePathToFileURL(path_prefix.AppendASCII("bot1.html"))); | |
49 NavigateToURL(bot1); // To help verify that Home does something. | |
50 | |
51 ASSERT_TRUE(Home()); | |
52 | |
53 GURL url; | |
54 ASSERT_TRUE(active_browser()->GetActiveTab()->GetCurrentURL(&url)); | |
55 EXPECT_EQ(GURL(chrome::kAboutBlankURL), url); | |
56 | |
57 std::wstring title; | |
58 ASSERT_TRUE(active_browser()->GetActiveTab()->GetTabTitle(&title)); | |
59 EXPECT_EQ(L"", title); | |
60 } | |
61 | |
62 TEST_F(AutomatedUITestBase, NewTab) { | 35 TEST_F(AutomatedUITestBase, NewTab) { |
63 int tab_count; | 36 int tab_count; |
64 active_browser()->GetTabCount(&tab_count); | 37 active_browser()->GetTabCount(&tab_count); |
65 ASSERT_EQ(1, tab_count); | 38 ASSERT_EQ(1, tab_count); |
66 NewTab(); | 39 NewTab(); |
67 active_browser()->GetTabCount(&tab_count); | 40 active_browser()->GetTabCount(&tab_count); |
68 ASSERT_EQ(2, tab_count); | 41 ASSERT_EQ(2, tab_count); |
69 NewTab(); | 42 NewTab(); |
70 active_browser()->GetTabCount(&tab_count); | 43 active_browser()->GetTabCount(&tab_count); |
71 ASSERT_EQ(3, tab_count); | 44 ASSERT_EQ(3, tab_count); |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 ASSERT_TRUE(BackButton()); | 287 ASSERT_TRUE(BackButton()); |
315 ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url)); | 288 ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url)); |
316 ASSERT_EQ(url1, url); | 289 ASSERT_EQ(url1, url); |
317 ASSERT_TRUE(ForwardButton()); | 290 ASSERT_TRUE(ForwardButton()); |
318 ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url)); | 291 ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url)); |
319 ASSERT_EQ(url2, url); | 292 ASSERT_EQ(url2, url); |
320 ASSERT_TRUE(ReloadPage()); | 293 ASSERT_TRUE(ReloadPage()); |
321 ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url)); | 294 ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url)); |
322 ASSERT_EQ(url2, url); | 295 ASSERT_EQ(url2, url); |
323 } | 296 } |
324 | |
325 TEST_F(AutomatedUITestBase, SelectTab) { | |
326 FilePath filename(test_data_directory_); | |
327 filename = filename.AppendASCII("title2.html"); | |
328 GURL url = net::FilePathToFileURL(filename); | |
329 | |
330 ASSERT_TRUE(active_browser()->AppendTab(url)); | |
331 ASSERT_TRUE(active_browser()->AppendTab(url)); | |
332 | |
333 int active_tab_index; | |
334 ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index)); | |
335 ASSERT_EQ(2, active_tab_index); | |
336 | |
337 ASSERT_TRUE(SelectNextTab()); | |
338 ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index)); | |
339 ASSERT_EQ(0, active_tab_index); | |
340 | |
341 ASSERT_TRUE(SelectNextTab()); | |
342 ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index)); | |
343 ASSERT_EQ(1, active_tab_index); | |
344 | |
345 ASSERT_TRUE(SelectPreviousTab()); | |
346 ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index)); | |
347 ASSERT_EQ(0, active_tab_index); | |
348 | |
349 ASSERT_TRUE(SelectPreviousTab()); | |
350 ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index)); | |
351 ASSERT_EQ(2, active_tab_index); | |
352 | |
353 ASSERT_TRUE(SelectPreviousTab()); | |
354 ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index)); | |
355 ASSERT_EQ(1, active_tab_index); | |
356 | |
357 ASSERT_TRUE(SelectNextTab()); | |
358 ASSERT_TRUE(active_browser()->GetActiveTabIndex(&active_tab_index)); | |
359 ASSERT_EQ(2, active_tab_index); | |
360 } | |
361 | |
362 // TODO(phajdan.jr): Enable ShowBookmarkBar on Mac. | |
363 #if !defined(OS_MACOSX) | |
364 TEST_F(AutomatedUITestBase, ShowBookmarkBar) { | |
365 ASSERT_TRUE(ShowBookmarkBar()); | |
366 bool is_visible; | |
367 bool is_animating; | |
368 ASSERT_TRUE(active_browser()->GetBookmarkBarVisibility(&is_visible, | |
369 &is_animating)); | |
370 ASSERT_TRUE(is_visible); | |
371 ASSERT_FALSE(is_animating); | |
372 | |
373 // Try second time to make sure it won't make the bookmark bar | |
374 // disappear. | |
375 ASSERT_TRUE(ShowBookmarkBar()); | |
376 ASSERT_TRUE(active_browser()->GetBookmarkBarVisibility(&is_visible, | |
377 &is_animating)); | |
378 ASSERT_TRUE(is_visible); | |
379 ASSERT_FALSE(is_animating); | |
380 } | |
381 #endif // !defined(OS_MACOSX) | |
382 | |
383 TEST_F(AutomatedUITestBase, ShowDownloads) { | |
384 ASSERT_TRUE(ShowDownloads()); | |
385 GURL url; | |
386 ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url)); | |
387 ASSERT_EQ(GURL(chrome::kChromeUIDownloadsURL), url); | |
388 } | |
389 | |
390 TEST_F(AutomatedUITestBase, ShowHistory) { | |
391 ASSERT_TRUE(ShowHistory()); | |
392 GURL url; | |
393 ASSERT_TRUE(GetActiveTab()->GetCurrentURL(&url)); | |
394 ASSERT_EQ(GURL(chrome::kChromeUIHistoryURL), url); | |
395 } | |
OLD | NEW |