| 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/bind.h" | 7 #include "base/bind.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/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 42 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
| 43 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" | 43 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" |
| 44 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 44 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 45 #include "chrome/common/chrome_notification_types.h" | 45 #include "chrome/common/chrome_notification_types.h" |
| 46 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
| 47 #include "chrome/common/extensions/extension.h" | 47 #include "chrome/common/extensions/extension.h" |
| 48 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
| 49 #include "chrome/test/base/in_process_browser_test.h" | 49 #include "chrome/test/base/in_process_browser_test.h" |
| 50 #include "chrome/test/base/ui_test_utils.h" | 50 #include "chrome/test/base/ui_test_utils.h" |
| 51 #include "content/public/browser/favicon_status.h" | 51 #include "content/public/browser/favicon_status.h" |
| 52 #include "content/public/browser/host_zoom_map.h" |
| 52 #include "content/public/browser/interstitial_page.h" | 53 #include "content/public/browser/interstitial_page.h" |
| 53 #include "content/public/browser/interstitial_page_delegate.h" | 54 #include "content/public/browser/interstitial_page_delegate.h" |
| 54 #include "content/public/browser/navigation_entry.h" | 55 #include "content/public/browser/navigation_entry.h" |
| 55 #include "content/public/browser/notification_service.h" | |
| 56 #include "content/public/browser/notification_source.h" | |
| 57 #include "content/public/browser/render_process_host.h" | 56 #include "content/public/browser/render_process_host.h" |
| 58 #include "content/public/browser/render_view_host.h" | 57 #include "content/public/browser/render_view_host.h" |
| 59 #include "content/public/browser/render_widget_host_view.h" | 58 #include "content/public/browser/render_widget_host_view.h" |
| 60 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
| 61 #include "content/public/browser/web_contents_observer.h" | 60 #include "content/public/browser/web_contents_observer.h" |
| 62 #include "content/public/common/page_transition_types.h" | 61 #include "content/public/common/page_transition_types.h" |
| 63 #include "content/public/common/renderer_preferences.h" | 62 #include "content/public/common/renderer_preferences.h" |
| 64 #include "content/public/common/url_constants.h" | 63 #include "content/public/common/url_constants.h" |
| 65 #include "content/public/test/browser_test_utils.h" | 64 #include "content/public/test/browser_test_utils.h" |
| 66 #include "content/public/test/test_navigation_observer.h" | 65 #include "content/public/test/test_navigation_observer.h" |
| (...skipping 1248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1314 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); |
| 1316 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); | 1315 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); |
| 1317 // Set Incognito to AVAILABLE. | 1316 // Set Incognito to AVAILABLE. |
| 1318 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), | 1317 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), |
| 1319 IncognitoModePrefs::ENABLED); | 1318 IncognitoModePrefs::ENABLED); |
| 1320 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI. | 1319 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI. |
| 1321 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1320 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); |
| 1322 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); | 1321 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); |
| 1323 } | 1322 } |
| 1324 | 1323 |
| 1324 namespace { |
| 1325 |
| 1326 void OnZoomLevelChanged(const base::Closure& callback, |
| 1327 const std::string& host) { |
| 1328 callback.Run(); |
| 1329 } |
| 1330 |
| 1331 } // namespace |
| 1332 |
| 1325 #if defined(OS_WIN) | 1333 #if defined(OS_WIN) |
| 1326 // Flakes regularly on Windows XP | 1334 // Flakes regularly on Windows XP |
| 1327 // http://crbug.com/146040 | 1335 // http://crbug.com/146040 |
| 1328 #define MAYBE_PageZoom DISABLED_PageZoom | 1336 #define MAYBE_PageZoom DISABLED_PageZoom |
| 1329 #else | 1337 #else |
| 1330 #define MAYBE_PageZoom PageZoom | 1338 #define MAYBE_PageZoom PageZoom |
| 1331 #endif | 1339 #endif |
| 1332 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { | 1340 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { |
| 1333 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 1341 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1334 bool enable_plus, enable_minus; | 1342 bool enable_plus, enable_minus; |
| 1335 | 1343 |
| 1336 content::WindowedNotificationObserver zoom_in_observer( | 1344 { |
| 1337 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1345 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1338 content::NotificationService::AllSources()); | 1346 new content::MessageLoopRunner); |
| 1339 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); | 1347 content::HostZoomMap::ZoomLevelChangedCallback callback( |
| 1340 zoom_in_observer.Wait(); | 1348 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 1341 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); | 1349 content::HostZoomMap::GetForBrowserContext( |
| 1342 EXPECT_TRUE(enable_plus); | 1350 browser()->profile())->AddZoomLevelChangedCallback(callback); |
| 1343 EXPECT_TRUE(enable_minus); | 1351 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); |
| 1352 loop_runner->Run(); |
| 1353 content::HostZoomMap::GetForBrowserContext( |
| 1354 browser()->profile())->RemoveZoomLevelChangedCallback(callback); |
| 1355 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); |
| 1356 EXPECT_TRUE(enable_plus); |
| 1357 EXPECT_TRUE(enable_minus); |
| 1358 } |
| 1344 | 1359 |
| 1345 content::WindowedNotificationObserver zoom_reset_observer( | 1360 { |
| 1346 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1361 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1347 content::NotificationService::AllSources()); | 1362 new content::MessageLoopRunner); |
| 1348 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 1363 content::HostZoomMap::ZoomLevelChangedCallback callback( |
| 1349 zoom_reset_observer.Wait(); | 1364 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 1350 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100); | 1365 content::HostZoomMap::GetForBrowserContext( |
| 1351 EXPECT_TRUE(enable_plus); | 1366 browser()->profile())->AddZoomLevelChangedCallback(callback); |
| 1352 EXPECT_TRUE(enable_minus); | 1367 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
| 1368 loop_runner->Run(); |
| 1369 content::HostZoomMap::GetForBrowserContext( |
| 1370 browser()->profile())->RemoveZoomLevelChangedCallback(callback); |
| 1371 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100); |
| 1372 EXPECT_TRUE(enable_plus); |
| 1373 EXPECT_TRUE(enable_minus); |
| 1374 } |
| 1353 | 1375 |
| 1354 content::WindowedNotificationObserver zoom_out_observer( | 1376 { |
| 1355 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1377 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1356 content::NotificationService::AllSources()); | 1378 new content::MessageLoopRunner); |
| 1357 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); | 1379 content::HostZoomMap::ZoomLevelChangedCallback callback( |
| 1358 zoom_out_observer.Wait(); | 1380 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 1359 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90); | 1381 content::HostZoomMap::GetForBrowserContext( |
| 1360 EXPECT_TRUE(enable_plus); | 1382 browser()->profile())->AddZoomLevelChangedCallback(callback); |
| 1361 EXPECT_TRUE(enable_minus); | 1383 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); |
| 1384 loop_runner->Run(); |
| 1385 content::HostZoomMap::GetForBrowserContext( |
| 1386 browser()->profile())->RemoveZoomLevelChangedCallback(callback); |
| 1387 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90); |
| 1388 EXPECT_TRUE(enable_plus); |
| 1389 EXPECT_TRUE(enable_minus); |
| 1390 } |
| 1362 | 1391 |
| 1363 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 1392 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
| 1364 } | 1393 } |
| 1365 | 1394 |
| 1366 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { | 1395 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { |
| 1367 ASSERT_TRUE(test_server()->Start()); | 1396 ASSERT_TRUE(test_server()->Start()); |
| 1368 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1397 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1369 GURL url(test_server()->GetURL("empty.html")); | 1398 GURL url(test_server()->GetURL("empty.html")); |
| 1370 ui_test_utils::NavigateToURL(browser(), url); | 1399 ui_test_utils::NavigateToURL(browser(), url); |
| 1371 | 1400 |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2016 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
| 1988 } | 2017 } |
| 1989 | 2018 |
| 1990 // Shift-middle-clicks open in a foreground tab. | 2019 // Shift-middle-clicks open in a foreground tab. |
| 1991 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { | 2020 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { |
| 1992 int modifiers = WebKit::WebInputEvent::ShiftKey; | 2021 int modifiers = WebKit::WebInputEvent::ShiftKey; |
| 1993 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 2022 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; |
| 1994 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2023 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
| 1995 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2024 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
| 1996 } | 2025 } |
| OLD | NEW |