| 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 class PageZoomObserver : public content::HostZoomMap::Observer { |
| 1321 public: |
| 1322 PageZoomObserver(content::HostZoomMap* map, |
| 1323 const base::Closure& callback) |
| 1324 : content::HostZoomMap::Observer(map), |
| 1325 callback_(callback) { |
| 1326 } |
| 1327 |
| 1328 virtual void OnZoomLevelChanged(const std::string& host) OVERRIDE { |
| 1329 callback_.Run(); |
| 1330 } |
| 1331 |
| 1332 private: |
| 1333 base::Closure callback_; |
| 1334 |
| 1335 DISALLOW_COPY_AND_ASSIGN(PageZoomObserver); |
| 1336 }; |
| 1337 |
| 1338 } // namespace |
| 1339 |
| 1319 #if defined(OS_WIN) | 1340 #if defined(OS_WIN) |
| 1320 // Flakes regularly on Windows XP | 1341 // Flakes regularly on Windows XP |
| 1321 // http://crbug.com/146040 | 1342 // http://crbug.com/146040 |
| 1322 #define MAYBE_PageZoom DISABLED_PageZoom | 1343 #define MAYBE_PageZoom DISABLED_PageZoom |
| 1323 #else | 1344 #else |
| 1324 #define MAYBE_PageZoom PageZoom | 1345 #define MAYBE_PageZoom PageZoom |
| 1325 #endif | 1346 #endif |
| 1326 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { | 1347 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { |
| 1327 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 1348 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1328 bool enable_plus, enable_minus; | 1349 bool enable_plus, enable_minus; |
| 1329 | 1350 |
| 1330 content::WindowedNotificationObserver zoom_in_observer( | 1351 { |
| 1331 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1352 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1332 content::NotificationService::AllSources()); | 1353 new content::MessageLoopRunner); |
| 1333 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); | 1354 PageZoomObserver zoom_observer( |
| 1334 zoom_in_observer.Wait(); | 1355 content::HostZoomMap::GetForBrowserContext(browser()->profile()), |
| 1335 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); | 1356 loop_runner->QuitClosure()); |
| 1336 EXPECT_TRUE(enable_plus); | 1357 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); |
| 1337 EXPECT_TRUE(enable_minus); | 1358 loop_runner->Run(); |
| 1359 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); |
| 1360 EXPECT_TRUE(enable_plus); |
| 1361 EXPECT_TRUE(enable_minus); |
| 1362 } |
| 1338 | 1363 |
| 1339 content::WindowedNotificationObserver zoom_reset_observer( | 1364 { |
| 1340 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1365 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1341 content::NotificationService::AllSources()); | 1366 new content::MessageLoopRunner); |
| 1342 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 1367 PageZoomObserver zoom_observer( |
| 1343 zoom_reset_observer.Wait(); | 1368 content::HostZoomMap::GetForBrowserContext(browser()->profile()), |
| 1344 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100); | 1369 loop_runner->QuitClosure()); |
| 1345 EXPECT_TRUE(enable_plus); | 1370 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
| 1346 EXPECT_TRUE(enable_minus); | 1371 loop_runner->Run(); |
| 1372 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100); |
| 1373 EXPECT_TRUE(enable_plus); |
| 1374 EXPECT_TRUE(enable_minus); |
| 1375 } |
| 1347 | 1376 |
| 1348 content::WindowedNotificationObserver zoom_out_observer( | 1377 { |
| 1349 content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | 1378 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1350 content::NotificationService::AllSources()); | 1379 new content::MessageLoopRunner); |
| 1351 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); | 1380 PageZoomObserver zoom_observer( |
| 1352 zoom_out_observer.Wait(); | 1381 content::HostZoomMap::GetForBrowserContext(browser()->profile()), |
| 1353 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90); | 1382 loop_runner->QuitClosure()); |
| 1354 EXPECT_TRUE(enable_plus); | 1383 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); |
| 1355 EXPECT_TRUE(enable_minus); | 1384 loop_runner->Run(); |
| 1385 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90); |
| 1386 EXPECT_TRUE(enable_plus); |
| 1387 EXPECT_TRUE(enable_minus); |
| 1388 } |
| 1356 | 1389 |
| 1357 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); | 1390 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); |
| 1358 } | 1391 } |
| 1359 | 1392 |
| 1360 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { | 1393 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { |
| 1361 ASSERT_TRUE(test_server()->Start()); | 1394 ASSERT_TRUE(test_server()->Start()); |
| 1362 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 1395 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1363 GURL url(test_server()->GetURL("empty.html")); | 1396 GURL url(test_server()->GetURL("empty.html")); |
| 1364 ui_test_utils::NavigateToURL(browser(), url); | 1397 ui_test_utils::NavigateToURL(browser(), url); |
| 1365 | 1398 |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1981 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2014 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
| 1982 } | 2015 } |
| 1983 | 2016 |
| 1984 // Shift-middle-clicks open in a foreground tab. | 2017 // Shift-middle-clicks open in a foreground tab. |
| 1985 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { | 2018 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { |
| 1986 int modifiers = WebKit::WebInputEvent::ShiftKey; | 2019 int modifiers = WebKit::WebInputEvent::ShiftKey; |
| 1987 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; | 2020 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; |
| 1988 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; | 2021 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; |
| 1989 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); | 2022 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); |
| 1990 } | 2023 } |
| OLD | NEW |