| OLD | NEW |
| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 406 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 407 ASSERT_EQ(0, active_tab_index); | 407 ASSERT_EQ(0, active_tab_index); |
| 408 | 408 |
| 409 ASSERT_TRUE(window->ActivateTab(1)); | 409 ASSERT_TRUE(window->ActivateTab(1)); |
| 410 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); | 410 ASSERT_TRUE(window->GetActiveTabIndex(&active_tab_index)); |
| 411 ASSERT_EQ(1, active_tab_index); | 411 ASSERT_EQ(1, active_tab_index); |
| 412 } | 412 } |
| 413 | 413 |
| 414 // http://crbug.com/98071 | 414 // http://crbug.com/98071 |
| 415 #if defined(OS_MACOSX) | 415 #if defined(OS_MACOSX) |
| 416 #define MAYBE_GetTabTitle FLAKY_GetTabTitle | 416 #define MAYBE_GetTabTitle DISABLED_GetTabTitle |
| 417 #else | 417 #else |
| 418 #define MAYBE_GetTabTitle GetTabTitle | 418 #define MAYBE_GetTabTitle GetTabTitle |
| 419 #endif | 419 #endif |
| 420 TEST_F(AutomationProxyTest2, MAYBE_GetTabTitle) { | 420 TEST_F(AutomationProxyTest2, MAYBE_GetTabTitle) { |
| 421 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 421 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 422 ASSERT_TRUE(window.get()); | 422 ASSERT_TRUE(window.get()); |
| 423 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 423 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 424 ASSERT_TRUE(tab.get()); | 424 ASSERT_TRUE(tab.get()); |
| 425 std::wstring title; | 425 std::wstring title; |
| 426 ASSERT_TRUE(tab->GetTabTitle(&title)); | 426 ASSERT_TRUE(tab->GetTabTitle(&title)); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 ASSERT_TRUE(window.get()); | 509 ASSERT_TRUE(window.get()); |
| 510 | 510 |
| 511 ASSERT_TRUE(window->RunCommand(IDC_SHOW_DOWNLOADS)); | 511 ASSERT_TRUE(window->RunCommand(IDC_SHOW_DOWNLOADS)); |
| 512 | 512 |
| 513 // We expect the RunCommand above to wait until the title is updated. | 513 // We expect the RunCommand above to wait until the title is updated. |
| 514 EXPECT_EQ(L"Downloads", GetActiveTabTitle()); | 514 EXPECT_EQ(L"Downloads", GetActiveTabTitle()); |
| 515 } | 515 } |
| 516 | 516 |
| 517 // http://crbug.com/109642 | 517 // http://crbug.com/109642 |
| 518 #if defined(OS_MACOSX) | 518 #if defined(OS_MACOSX) |
| 519 #define MAYBE_AcceleratorExtensions FLAKY_AcceleratorExtensions | 519 #define MAYBE_AcceleratorExtensions DISABLED_AcceleratorExtensions |
| 520 #else | 520 #else |
| 521 #define MAYBE_AcceleratorExtensions AcceleratorExtensions | 521 #define MAYBE_AcceleratorExtensions AcceleratorExtensions |
| 522 #endif | 522 #endif |
| 523 TEST_F(AutomationProxyTest, MAYBE_AcceleratorExtensions) { | 523 TEST_F(AutomationProxyTest, MAYBE_AcceleratorExtensions) { |
| 524 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 524 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 525 ASSERT_TRUE(window.get()); | 525 ASSERT_TRUE(window.get()); |
| 526 | 526 |
| 527 ASSERT_TRUE(window->RunCommand(IDC_MANAGE_EXTENSIONS)); | 527 ASSERT_TRUE(window->RunCommand(IDC_MANAGE_EXTENSIONS)); |
| 528 | 528 |
| 529 EXPECT_EQ("chrome://settings/extensions", GetActiveTabURL().spec()); | 529 EXPECT_EQ("chrome://settings/extensions", GetActiveTabURL().spec()); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath2, jscript2, &actual)); | 650 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath2, jscript2, &actual)); |
| 651 ASSERT_EQ(L"SPAN", actual); | 651 ASSERT_EQ(L"SPAN", actual); |
| 652 | 652 |
| 653 std::wstring xpath3 = L"/html/body/iframe\n/html/body/iframe"; | 653 std::wstring xpath3 = L"/html/body/iframe\n/html/body/iframe"; |
| 654 std::wstring jscript3 = CreateJSStringForDOMQuery(L"mydiv"); | 654 std::wstring jscript3 = CreateJSStringForDOMQuery(L"mydiv"); |
| 655 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath3, jscript3, &actual)); | 655 ASSERT_TRUE(tab->ExecuteAndExtractString(xpath3, jscript3, &actual)); |
| 656 ASSERT_EQ(L"DIV", actual); | 656 ASSERT_EQ(L"DIV", actual); |
| 657 } | 657 } |
| 658 | 658 |
| 659 // Flaky, http://crbug.com/70937 | 659 // Flaky, http://crbug.com/70937 |
| 660 TEST_F(AutomationProxyTest, FLAKY_BlockedPopupTest) { | 660 TEST_F(AutomationProxyTest, DISABLED_BlockedPopupTest) { |
| 661 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 661 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 662 ASSERT_TRUE(window.get()); | 662 ASSERT_TRUE(window.get()); |
| 663 | 663 |
| 664 scoped_refptr<TabProxy> tab(window->GetTab(0)); | 664 scoped_refptr<TabProxy> tab(window->GetTab(0)); |
| 665 ASSERT_TRUE(tab.get()); | 665 ASSERT_TRUE(tab.get()); |
| 666 | 666 |
| 667 FilePath filename(test_data_directory_); | 667 FilePath filename(test_data_directory_); |
| 668 filename = filename.AppendASCII("constrained_files"); | 668 filename = filename.AppendASCII("constrained_files"); |
| 669 filename = filename.AppendASCII("constrained_window.html"); | 669 filename = filename.AppendASCII("constrained_window.html"); |
| 670 | 670 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 | 912 |
| 913 ExternalTabUITest::ExternalTabUITest() : UITest(MessageLoop::TYPE_UI) {} | 913 ExternalTabUITest::ExternalTabUITest() : UITest(MessageLoop::TYPE_UI) {} |
| 914 | 914 |
| 915 // Replace the default automation proxy with our mock client. | 915 // Replace the default automation proxy with our mock client. |
| 916 ProxyLauncher* ExternalTabUITest::CreateProxyLauncher() { | 916 ProxyLauncher* ExternalTabUITest::CreateProxyLauncher() { |
| 917 return new ExternalTabUITestMockLauncher(&mock_); | 917 return new ExternalTabUITestMockLauncher(&mock_); |
| 918 } | 918 } |
| 919 | 919 |
| 920 // Create with specifying a url | 920 // Create with specifying a url |
| 921 // Flaky, http://crbug.com/32293 | 921 // Flaky, http://crbug.com/32293 |
| 922 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab1) { | 922 TEST_F(ExternalTabUITest, DISABLED_CreateExternalTab1) { |
| 923 scoped_refptr<TabProxy> tab; | 923 scoped_refptr<TabProxy> tab; |
| 924 TimedMessageLoopRunner loop(MessageLoop::current()); | 924 TimedMessageLoopRunner loop(MessageLoop::current()); |
| 925 ASSERT_THAT(mock_, testing::NotNull()); | 925 ASSERT_THAT(mock_, testing::NotNull()); |
| 926 | 926 |
| 927 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) | 927 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) |
| 928 .Times(testing::AnyNumber()); | 928 .Times(testing::AnyNumber()); |
| 929 | 929 |
| 930 EXPECT_CALL(*mock_, OnDidNavigate(testing::_)) | 930 EXPECT_CALL(*mock_, OnDidNavigate(testing::_)) |
| 931 .Times(1) | 931 .Times(1) |
| 932 .WillOnce(testing::InvokeWithoutArgs(mock_, | 932 .WillOnce(testing::InvokeWithoutArgs(mock_, |
| 933 &ExternalTabUITestMockClient::DestroyHostWindow)); | 933 &ExternalTabUITestMockClient::DestroyHostWindow)); |
| 934 | 934 |
| 935 EXPECT_CALL(*mock_, HandleClosed(1)) | 935 EXPECT_CALL(*mock_, HandleClosed(1)) |
| 936 .Times(1) | 936 .Times(1) |
| 937 .WillOnce(QUIT_LOOP(&loop)); | 937 .WillOnce(QUIT_LOOP(&loop)); |
| 938 | 938 |
| 939 tab = mock_->CreateTabWithUrl(GURL(simple_data_url)); | 939 tab = mock_->CreateTabWithUrl(GURL(simple_data_url)); |
| 940 loop.RunFor(TestTimeouts::action_max_timeout_ms()); | 940 loop.RunFor(TestTimeouts::action_max_timeout_ms()); |
| 941 } | 941 } |
| 942 | 942 |
| 943 // Create with empty url and then navigate | 943 // Create with empty url and then navigate |
| 944 // Flaky, http://crbug.com/32293 | 944 // Flaky, http://crbug.com/32293 |
| 945 TEST_F(ExternalTabUITest, FLAKY_CreateExternalTab2) { | 945 TEST_F(ExternalTabUITest, DISABLED_CreateExternalTab2) { |
| 946 scoped_refptr<TabProxy> tab; | 946 scoped_refptr<TabProxy> tab; |
| 947 TimedMessageLoopRunner loop(MessageLoop::current()); | 947 TimedMessageLoopRunner loop(MessageLoop::current()); |
| 948 ASSERT_THAT(mock_, testing::NotNull()); | 948 ASSERT_THAT(mock_, testing::NotNull()); |
| 949 | 949 |
| 950 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) | 950 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) |
| 951 .Times(testing::AnyNumber()); | 951 .Times(testing::AnyNumber()); |
| 952 | 952 |
| 953 EXPECT_CALL(*mock_, OnDidNavigate(testing::_)) | 953 EXPECT_CALL(*mock_, OnDidNavigate(testing::_)) |
| 954 .Times(1) | 954 .Times(1) |
| 955 .WillOnce(testing::InvokeWithoutArgs(mock_, | 955 .WillOnce(testing::InvokeWithoutArgs(mock_, |
| 956 &ExternalTabUITestMockClient::DestroyHostWindow)); | 956 &ExternalTabUITestMockClient::DestroyHostWindow)); |
| 957 | 957 |
| 958 EXPECT_CALL(*mock_, HandleClosed(1)) | 958 EXPECT_CALL(*mock_, HandleClosed(1)) |
| 959 .Times(1) | 959 .Times(1) |
| 960 .WillOnce(QUIT_LOOP(&loop)); | 960 .WillOnce(QUIT_LOOP(&loop)); |
| 961 | 961 |
| 962 tab = mock_->CreateTabWithUrl(GURL()); | 962 tab = mock_->CreateTabWithUrl(GURL()); |
| 963 mock_->NavigateInExternalTab(tab->handle(), GURL(simple_data_url)); | 963 mock_->NavigateInExternalTab(tab->handle(), GURL(simple_data_url)); |
| 964 loop.RunFor(TestTimeouts::action_max_timeout_ms()); | 964 loop.RunFor(TestTimeouts::action_max_timeout_ms()); |
| 965 } | 965 } |
| 966 | 966 |
| 967 // FLAKY: http://crbug.com/60409 | 967 // FLAKY: http://crbug.com/60409 |
| 968 TEST_F(ExternalTabUITest, FLAKY_IncognitoMode) { | 968 TEST_F(ExternalTabUITest, DISABLED_IncognitoMode) { |
| 969 scoped_refptr<TabProxy> tab; | 969 scoped_refptr<TabProxy> tab; |
| 970 TimedMessageLoopRunner loop(MessageLoop::current()); | 970 TimedMessageLoopRunner loop(MessageLoop::current()); |
| 971 ASSERT_THAT(mock_, testing::NotNull()); | 971 ASSERT_THAT(mock_, testing::NotNull()); |
| 972 | 972 |
| 973 GURL url("http://anatomyofmelancholy.net"); | 973 GURL url("http://anatomyofmelancholy.net"); |
| 974 std::string cookie = "robert=burton; expires=Thu, 13 Oct 2011 05:04:03 UTC;"; | 974 std::string cookie = "robert=burton; expires=Thu, 13 Oct 2011 05:04:03 UTC;"; |
| 975 | 975 |
| 976 EXPECT_CALL(*mock_, HandleClosed(1)).Times(1); | 976 EXPECT_CALL(*mock_, HandleClosed(1)).Times(1); |
| 977 | 977 |
| 978 ExternalTabSettings incognito = | 978 ExternalTabSettings incognito = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1000 tab = mock_->CreateTabWithUrl(GURL()); | 1000 tab = mock_->CreateTabWithUrl(GURL()); |
| 1001 EXPECT_TRUE(tab->GetCookieByName(url, "robert", &value_result)); | 1001 EXPECT_TRUE(tab->GetCookieByName(url, "robert", &value_result)); |
| 1002 EXPECT_EQ("", value_result); | 1002 EXPECT_EQ("", value_result); |
| 1003 EXPECT_CALL(*mock_, HandleClosed(1)).Times(1); | 1003 EXPECT_CALL(*mock_, HandleClosed(1)).Times(1); |
| 1004 mock_->DestroyHostWindow(); | 1004 mock_->DestroyHostWindow(); |
| 1005 CloseBrowserAndServer(); | 1005 CloseBrowserAndServer(); |
| 1006 tab = NULL; | 1006 tab = NULL; |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 // FLAKY: http://crbug.com/44617 | 1009 // FLAKY: http://crbug.com/44617 |
| 1010 TEST_F(ExternalTabUITest, FLAKY_TabPostMessage) { | 1010 TEST_F(ExternalTabUITest, DISABLED_TabPostMessage) { |
| 1011 scoped_refptr<TabProxy> tab; | 1011 scoped_refptr<TabProxy> tab; |
| 1012 TimedMessageLoopRunner loop(MessageLoop::current()); | 1012 TimedMessageLoopRunner loop(MessageLoop::current()); |
| 1013 ASSERT_THAT(mock_, testing::NotNull()); | 1013 ASSERT_THAT(mock_, testing::NotNull()); |
| 1014 | 1014 |
| 1015 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) | 1015 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) |
| 1016 .Times(testing::AnyNumber()); | 1016 .Times(testing::AnyNumber()); |
| 1017 EXPECT_CALL(*mock_, OnLoad(_)).Times(testing::AnyNumber()); | 1017 EXPECT_CALL(*mock_, OnLoad(_)).Times(testing::AnyNumber()); |
| 1018 | 1018 |
| 1019 std::string content = | 1019 std::string content = |
| 1020 "data:text/html,<html><head><script>" | 1020 "data:text/html,<html><head><script>" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1044 &ExternalTabUITestMockClient::DestroyHostWindow)), | 1044 &ExternalTabUITestMockClient::DestroyHostWindow)), |
| 1045 QUIT_LOOP_SOON(&loop, 50))); | 1045 QUIT_LOOP_SOON(&loop, 50))); |
| 1046 | 1046 |
| 1047 EXPECT_CALL(*mock_, HandleClosed(1)).Times(1); | 1047 EXPECT_CALL(*mock_, HandleClosed(1)).Times(1); |
| 1048 | 1048 |
| 1049 tab = mock_->CreateTabWithUrl(GURL(content)); | 1049 tab = mock_->CreateTabWithUrl(GURL(content)); |
| 1050 loop.RunFor(TestTimeouts::action_max_timeout_ms()); | 1050 loop.RunFor(TestTimeouts::action_max_timeout_ms()); |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 // Flaky: http://crbug.com/62143 | 1053 // Flaky: http://crbug.com/62143 |
| 1054 TEST_F(ExternalTabUITest, FLAKY_PostMessageTarget) { | 1054 TEST_F(ExternalTabUITest, DISABLED_PostMessageTarget) { |
| 1055 net::TestServer test_server( | 1055 net::TestServer test_server( |
| 1056 net::TestServer::TYPE_HTTP, | 1056 net::TestServer::TYPE_HTTP, |
| 1057 FilePath(FILE_PATH_LITERAL("chrome/test/data/external_tab"))); | 1057 FilePath(FILE_PATH_LITERAL("chrome/test/data/external_tab"))); |
| 1058 ASSERT_TRUE(test_server.Start()); | 1058 ASSERT_TRUE(test_server.Start()); |
| 1059 | 1059 |
| 1060 scoped_refptr<TabProxy> tab; | 1060 scoped_refptr<TabProxy> tab; |
| 1061 TimedMessageLoopRunner loop(MessageLoop::current()); | 1061 TimedMessageLoopRunner loop(MessageLoop::current()); |
| 1062 ASSERT_THAT(mock_, testing::NotNull()); | 1062 ASSERT_THAT(mock_, testing::NotNull()); |
| 1063 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) | 1063 EXPECT_CALL(*mock_, OnNavigationStateChanged(_, _)) |
| 1064 .Times(testing::AnyNumber()); | 1064 .Times(testing::AnyNumber()); |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1393 mock_->CreateTabWithUrl(main_url); | 1393 mock_->CreateTabWithUrl(main_url); |
| 1394 loop.RunFor(TestTimeouts::action_max_timeout_ms()); | 1394 loop.RunFor(TestTimeouts::action_max_timeout_ms()); |
| 1395 | 1395 |
| 1396 EXPECT_CALL(*mock_, HandleClosed(1)); | 1396 EXPECT_CALL(*mock_, HandleClosed(1)); |
| 1397 ::DestroyWindow(foo_host); | 1397 ::DestroyWindow(foo_host); |
| 1398 mock_->DestroyHostWindow(); | 1398 mock_->DestroyHostWindow(); |
| 1399 } | 1399 } |
| 1400 #endif // defined(OS_WIN) | 1400 #endif // defined(OS_WIN) |
| 1401 | 1401 |
| 1402 // Flaky especially on Windows. See crbug.com/25039. | 1402 // Flaky especially on Windows. See crbug.com/25039. |
| 1403 TEST_F(AutomationProxyTest, FLAKY_AppModalDialogTest) { | 1403 TEST_F(AutomationProxyTest, DISABLED_AppModalDialogTest) { |
| 1404 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 1404 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 1405 ASSERT_TRUE(browser.get()); | 1405 ASSERT_TRUE(browser.get()); |
| 1406 scoped_refptr<TabProxy> tab(browser->GetTab(0)); | 1406 scoped_refptr<TabProxy> tab(browser->GetTab(0)); |
| 1407 ASSERT_TRUE(tab.get()); | 1407 ASSERT_TRUE(tab.get()); |
| 1408 | 1408 |
| 1409 bool modal_dialog_showing = false; | 1409 bool modal_dialog_showing = false; |
| 1410 ui::DialogButton button = ui::DIALOG_BUTTON_NONE; | 1410 ui::DialogButton button = ui::DIALOG_BUTTON_NONE; |
| 1411 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, | 1411 EXPECT_TRUE(automation()->GetShowingAppModalDialog(&modal_dialog_showing, |
| 1412 &button)); | 1412 &button)); |
| 1413 EXPECT_FALSE(modal_dialog_showing); | 1413 EXPECT_FALSE(modal_dialog_showing); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1580 | 1580 |
| 1581 std::string data; | 1581 std::string data; |
| 1582 ASSERT_NO_FATAL_FAILURE(AssertReadPNG(snapshot_path_, &data)); | 1582 ASSERT_NO_FATAL_FAILURE(AssertReadPNG(snapshot_path_, &data)); |
| 1583 EXPECT_STREQ(kReferenceMd5, base::MD5String(data).c_str()); | 1583 EXPECT_STREQ(kReferenceMd5, base::MD5String(data).c_str()); |
| 1584 if (CommandLine::ForCurrentProcess()->HasSwitch("dump-test-image")) { | 1584 if (CommandLine::ForCurrentProcess()->HasSwitch("dump-test-image")) { |
| 1585 FilePath path(FILE_PATH_LITERAL("snapshot.png")); | 1585 FilePath path(FILE_PATH_LITERAL("snapshot.png")); |
| 1586 EXPECT_EQ(file_util::WriteFile(path, &data[0], data.length()), | 1586 EXPECT_EQ(file_util::WriteFile(path, &data[0], data.length()), |
| 1587 static_cast<int>(data.length())); | 1587 static_cast<int>(data.length())); |
| 1588 } | 1588 } |
| 1589 } | 1589 } |
| OLD | NEW |