OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 FILE_PATH_LITERAL("beforeunload.html"); | 149 FILE_PATH_LITERAL("beforeunload.html"); |
150 | 150 |
151 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); | 151 const base::FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); |
152 const base::FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); | 152 const base::FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); |
153 | 153 |
154 const base::FilePath::CharType kDocRoot[] = | 154 const base::FilePath::CharType kDocRoot[] = |
155 FILE_PATH_LITERAL("chrome/test/data"); | 155 FILE_PATH_LITERAL("chrome/test/data"); |
156 | 156 |
157 // Given a page title, returns the expected window caption string. | 157 // Given a page title, returns the expected window caption string. |
158 base::string16 WindowCaptionFromPageTitle(const base::string16& page_title) { | 158 base::string16 WindowCaptionFromPageTitle(const base::string16& page_title) { |
159 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) | 159 #if defined(OS_MACOSX) |
160 // On Mac or ChromeOS, we don't want to suffix the page title with | 160 // On Mac, we don't want to suffix the page title with the application name. |
161 // the application name. | |
162 if (page_title.empty()) | 161 if (page_title.empty()) |
163 return l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); | 162 return l10n_util::GetStringUTF16(IDS_BROWSER_WINDOW_MAC_TAB_UNTITLED); |
164 return page_title; | 163 return page_title; |
165 #else | 164 #else |
166 if (page_title.empty()) | 165 if (page_title.empty()) |
167 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 166 return l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
168 | 167 |
169 return l10n_util::GetStringFUTF16(IDS_BROWSER_WINDOW_TITLE_FORMAT, | 168 return l10n_util::GetStringFUTF16(IDS_BROWSER_WINDOW_TITLE_FORMAT, |
170 page_title); | 169 page_title); |
171 #endif | 170 #endif |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 }; | 369 }; |
371 | 370 |
372 // Launch the app on a page with no title, check that the app title was set | 371 // Launch the app on a page with no title, check that the app title was set |
373 // correctly. | 372 // correctly. |
374 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) { | 373 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) { |
375 ui_test_utils::NavigateToURL( | 374 ui_test_utils::NavigateToURL( |
376 browser(), ui_test_utils::GetTestUrl( | 375 browser(), ui_test_utils::GetTestUrl( |
377 base::FilePath(base::FilePath::kCurrentDirectory), | 376 base::FilePath(base::FilePath::kCurrentDirectory), |
378 base::FilePath(kTitle1File))); | 377 base::FilePath(kTitle1File))); |
379 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(ASCIIToUTF16("title1.html")), | 378 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(ASCIIToUTF16("title1.html")), |
380 browser()->GetWindowTitleForCurrentTab()); | 379 browser()->GetWindowTitleForCurrentTab( |
| 380 true /* include_app_name */)); |
381 base::string16 tab_title; | 381 base::string16 tab_title; |
382 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); | 382 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); |
383 EXPECT_EQ(ASCIIToUTF16("title1.html"), tab_title); | 383 EXPECT_EQ(ASCIIToUTF16("title1.html"), tab_title); |
384 } | 384 } |
385 | 385 |
386 // Check that a file:// URL displays the filename, but no path, with any ref or | 386 // Check that a file:// URL displays the filename, but no path, with any ref or |
387 // query parameters following it if the content does not have a <title> tag. | 387 // query parameters following it if the content does not have a <title> tag. |
388 // Specifically verify the cases where the ref or query parameters have a '/' | 388 // Specifically verify the cases where the ref or query parameters have a '/' |
389 // character in them. This is a regression test for | 389 // character in them. This is a regression test for |
390 // https://crbug.com/503003. | 390 // https://crbug.com/503003. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 // Launch the app, navigate to a page with a title, check that the app title | 430 // Launch the app, navigate to a page with a title, check that the app title |
431 // was set correctly. | 431 // was set correctly. |
432 IN_PROC_BROWSER_TEST_F(BrowserTest, Title) { | 432 IN_PROC_BROWSER_TEST_F(BrowserTest, Title) { |
433 ui_test_utils::NavigateToURL( | 433 ui_test_utils::NavigateToURL( |
434 browser(), ui_test_utils::GetTestUrl( | 434 browser(), ui_test_utils::GetTestUrl( |
435 base::FilePath(base::FilePath::kCurrentDirectory), | 435 base::FilePath(base::FilePath::kCurrentDirectory), |
436 base::FilePath(kTitle2File))); | 436 base::FilePath(kTitle2File))); |
437 const base::string16 test_title(ASCIIToUTF16("Title Of Awesomeness")); | 437 const base::string16 test_title(ASCIIToUTF16("Title Of Awesomeness")); |
438 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title), | 438 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(test_title), |
439 browser()->GetWindowTitleForCurrentTab()); | 439 browser()->GetWindowTitleForCurrentTab( |
| 440 true /* include_app_name */)); |
440 base::string16 tab_title; | 441 base::string16 tab_title; |
441 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); | 442 ASSERT_TRUE(ui_test_utils::GetCurrentTabTitle(browser(), &tab_title)); |
442 EXPECT_EQ(test_title, tab_title); | 443 EXPECT_EQ(test_title, tab_title); |
443 } | 444 } |
444 | 445 |
445 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) { | 446 IN_PROC_BROWSER_TEST_F(BrowserTest, JavascriptAlertActivatesTab) { |
446 GURL url(ui_test_utils::GetTestUrl(base::FilePath( | 447 GURL url(ui_test_utils::GetTestUrl(base::FilePath( |
447 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); | 448 base::FilePath::kCurrentDirectory), base::FilePath(kTitle1File))); |
448 ui_test_utils::NavigateToURL(browser(), url); | 449 ui_test_utils::NavigateToURL(browser(), url); |
449 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); | 450 AddTabAtIndex(0, url, ui::PAGE_TRANSITION_TYPED); |
(...skipping 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2844 Browser* browser = new Browser(params); | 2845 Browser* browser = new Browser(params); |
2845 gfx::Rect bounds = browser->window()->GetBounds(); | 2846 gfx::Rect bounds = browser->window()->GetBounds(); |
2846 | 2847 |
2847 // Should be EXPECT_EQ, but this width is inconsistent across platforms. | 2848 // Should be EXPECT_EQ, but this width is inconsistent across platforms. |
2848 // See https://crbug.com/567925. | 2849 // See https://crbug.com/567925. |
2849 EXPECT_GE(bounds.width(), 100); | 2850 EXPECT_GE(bounds.width(), 100); |
2850 EXPECT_EQ(122, bounds.height()); | 2851 EXPECT_EQ(122, bounds.height()); |
2851 browser->window()->Close(); | 2852 browser->window()->Close(); |
2852 } | 2853 } |
2853 } | 2854 } |
OLD | NEW |