| 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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); | 1308 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_OPTIONS)); |
| 1310 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); | 1309 EXPECT_FALSE(command_updater->IsCommandEnabled(IDC_IMPORT_SETTINGS)); |
| 1311 // Set Incognito to AVAILABLE. | 1310 // Set Incognito to AVAILABLE. |
| 1312 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), | 1311 IncognitoModePrefs::SetAvailability(popup_browser->profile()->GetPrefs(), |
| 1313 IncognitoModePrefs::ENABLED); | 1312 IncognitoModePrefs::ENABLED); |
| 1314 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI. | 1313 // OPTIONS and IMPORT_SETTINGS are still disabled since it is a non-normal UI. |
| 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 } | 1316 } |
| 1318 | 1317 |
| 1318 namespace { |
| 1319 |
| 1320 void OnZoomLevelChanged(const base::Closure& callback, |
| 1321 const std::string& host) { |
| 1322 callback.Run(); |
| 1323 } |
| 1324 |
| 1325 } // namespace |
| 1326 |
| 1319 #if defined(OS_WIN) | 1327 #if defined(OS_WIN) |
| 1320 // Flakes regularly on Windows XP | 1328 // Flakes regularly on Windows XP |
| 1321 // http://crbug.com/146040 | 1329 // http://crbug.com/146040 |
| 1322 #define MAYBE_PageZoom DISABLED_PageZoom | 1330 #define MAYBE_PageZoom DISABLED_PageZoom |
| 1323 #else | 1331 #else |
| 1324 #define MAYBE_PageZoom PageZoom | 1332 #define MAYBE_PageZoom PageZoom |
| 1325 #endif | 1333 #endif |
| 1326 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { | 1334 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { |
| 1327 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 1335 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1328 bool enable_plus, enable_minus; | 1336 bool enable_plus, enable_minus; |
| 1329 | 1337 |
| 1330 content::WindowedNotificationObserver zoom_in_observer( | 1338 { |
| 1331 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1339 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1332 content::NotificationService::AllSources()); | 1340 new content::MessageLoopRunner); |
| 1333 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); | 1341 content::HostZoomMap::GetForBrowserContext( |
| 1334 zoom_in_observer.Wait(); | 1342 browser()->profile())->AddZoomLevelChangedCallback( |
| 1335 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); | 1343 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 1336 EXPECT_TRUE(enable_plus); | 1344 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); |
| 1337 EXPECT_TRUE(enable_minus); | 1345 loop_runner->Run(); |
| 1346 content::HostZoomMap::GetForBrowserContext( |
| 1347 browser()->profile())->RemoveZoomLevelChangedCallback( |
| 1348 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 1349 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); |
| 1350 EXPECT_TRUE(enable_plus); |
| 1351 EXPECT_TRUE(enable_minus); |
| 1352 } |
| 1338 | 1353 |
| 1339 content::WindowedNotificationObserver zoom_reset_observer( | 1354 { |
| 1340 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1355 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1341 content::NotificationService::AllSources()); | 1356 new content::MessageLoopRunner); |
| 1342 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 1357 content::HostZoomMap::GetForBrowserContext( |
| 1343 zoom_reset_observer.Wait(); | 1358 browser()->profile())->AddZoomLevelChangedCallback( |
| 1344 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100); | 1359 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 1345 EXPECT_TRUE(enable_plus); | 1360 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
| 1346 EXPECT_TRUE(enable_minus); | 1361 loop_runner->Run(); |
| 1362 content::HostZoomMap::GetForBrowserContext( |
| 1363 browser()->profile())->RemoveZoomLevelChangedCallback( |
| 1364 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 1365 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100); |
| 1366 EXPECT_TRUE(enable_plus); |
| 1367 EXPECT_TRUE(enable_minus); |
| 1368 } |
| 1347 | 1369 |
| 1348 content::WindowedNotificationObserver zoom_out_observer( | 1370 { |
| 1349 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1371 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1350 content::NotificationService::AllSources()); | 1372 new content::MessageLoopRunner); |
| 1351 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); | 1373 content::HostZoomMap::GetForBrowserContext( |
| 1352 zoom_out_observer.Wait(); | 1374 browser()->profile())->AddZoomLevelChangedCallback( |
| 1353 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90); | 1375 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 1354 EXPECT_TRUE(enable_plus); | 1376 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); |
| 1355 EXPECT_TRUE(enable_minus); | 1377 loop_runner->Run(); |
| 1378 content::HostZoomMap::GetForBrowserContext( |
| 1379 browser()->profile())->RemoveZoomLevelChangedCallback( |
| 1380 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); |
| 1381 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90); |
| 1382 EXPECT_TRUE(enable_plus); |
| 1383 EXPECT_TRUE(enable_minus); |
| 1384 } |
| 1356 | 1385 |
| 1357 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 1386 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
| 1358 } | 1387 } |
| 1359 | 1388 |
| 1360 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { | 1389 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { |
| 1361 ASSERT_TRUE(test_server()->Start()); | 1390 ASSERT_TRUE(test_server()->Start()); |
| 1362 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1391 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1363 GURL url(test_server()->GetURL("empty.html")); | 1392 GURL url(test_server()->GetURL("empty.html")); |
| 1364 ui_test_utils::NavigateToURL(browser(), url); | 1393 ui_test_utils::NavigateToURL(browser(), url); |
| 1365 | 1394 |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2010 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
| 1982 } | 2011 } |
| 1983 | 2012 |
| 1984 // Shift-middle-clicks open in a foreground tab. | 2013 // Shift-middle-clicks open in a foreground tab. |
| 1985 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { | 2014 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { |
| 1986 int modifiers = WebKit::WebInputEvent::ShiftKey; | 2015 int modifiers = WebKit::WebInputEvent::ShiftKey; |
| 1987 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 2016 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; |
| 1988 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2017 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
| 1989 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2018 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
| 1990 } | 2019 } |
| OLD | NEW |