| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "chrome/browser/app_modal_dialog.h" |
| 8 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
| 12 #include "chrome/common/page_transition_types.h" |
| 11 #include "chrome/test/in_process_browser_test.h" | 13 #include "chrome/test/in_process_browser_test.h" |
| 12 #include "chrome/test/ui_test_utils.h" | 14 #include "chrome/test/ui_test_utils.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
| 15 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 // Given a page title, returns the expected window caption string. | 21 // Given a page title, returns the expected window caption string. |
| 20 std::wstring WindowCaptionFromPageTitle(std::wstring page_title) { | 22 std::wstring WindowCaptionFromPageTitle(std::wstring page_title) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 IN_PROC_BROWSER_TEST_F(BrowserTest, Title) { | 74 IN_PROC_BROWSER_TEST_F(BrowserTest, Title) { |
| 73 ui_test_utils::NavigateToURL(browser(), | 75 ui_test_utils::NavigateToURL(browser(), |
| 74 ui_test_utils::GetTestUrl(L".", L"title2.html")); | 76 ui_test_utils::GetTestUrl(L".", L"title2.html")); |
| 75 const std::wstring test_title(L"Title Of Awesomeness"); | 77 const std::wstring test_title(L"Title Of Awesomeness"); |
| 76 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title), | 78 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title), |
| 77 UTF16ToWideHack(browser()->GetCurrentPageTitle())); | 79 UTF16ToWideHack(browser()->GetCurrentPageTitle())); |
| 78 string16 tab_title; | 80 string16 tab_title; |
| 79 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); | 81 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); |
| 80 EXPECT_EQ(WideToUTF16(test_title), tab_title); | 82 EXPECT_EQ(WideToUTF16(test_title), tab_title); |
| 81 } | 83 } |
| 84 |
| 85 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) { |
| 86 GURL url(ui_test_utils::GetTestUrl(L".", L"title1.html")); |
| 87 ui_test_utils::NavigateToURL(browser(), url); |
| 88 browser()->AddTabWithURL(url, GURL(), PageTransition::TYPED, |
| 89 true, 0, false, NULL); |
| 90 EXPECT_EQ(2, browser()->tab_count()); |
| 91 EXPECT_EQ(0, browser()->selected_index()); |
| 92 TabContents* second_tab = browser()->GetTabContentsAt(1); |
| 93 ASSERT_TRUE(second_tab); |
| 94 second_tab->render_view_host()->ExecuteJavascriptInWebFrame(L"", |
| 95 L"alert('Activate!');"); |
| 96 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 97 alert->CloseModalDialog(); |
| 98 EXPECT_EQ(2, browser()->tab_count()); |
| 99 EXPECT_EQ(1, browser()->selected_index()); |
| 100 } |
| OLD | NEW |