Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 301733006: Zoom Extension API (chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Create ZoomController for guest web contents. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 1798
1799 } // namespace 1799 } // namespace
1800 1800
1801 #if defined(OS_WIN) 1801 #if defined(OS_WIN)
1802 // Flakes regularly on Windows XP 1802 // Flakes regularly on Windows XP
1803 // http://crbug.com/146040 1803 // http://crbug.com/146040
1804 #define MAYBE_PageZoom DISABLED_PageZoom 1804 #define MAYBE_PageZoom DISABLED_PageZoom
1805 #else 1805 #else
1806 #define MAYBE_PageZoom PageZoom 1806 #define MAYBE_PageZoom PageZoom
1807 #endif 1807 #endif
1808
1809 namespace {
1810
1811 int GetZoomPercent(const content::WebContents* contents,
1812 bool* enable_plus,
1813 bool* enable_minus) {
1814 int percent = ZoomController::FromWebContents(contents)->GetZoomPercent();
1815 *enable_plus = percent < contents->GetMaximumZoomPercent();
1816 *enable_minus = percent > contents->GetMinimumZoomPercent();
1817 return percent;
1818 }
1819
1820 } // namespace
1821
1808 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { 1822 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) {
1809 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 1823 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
1810 bool enable_plus, enable_minus; 1824 bool enable_plus, enable_minus;
1811 1825
1812 { 1826 {
1813 scoped_refptr<content::MessageLoopRunner> loop_runner( 1827 scoped_refptr<content::MessageLoopRunner> loop_runner(
1814 new content::MessageLoopRunner); 1828 new content::MessageLoopRunner);
1815 content::HostZoomMap::ZoomLevelChangedCallback callback( 1829 content::HostZoomMap::ZoomLevelChangedCallback callback(
1816 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); 1830 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure()));
1817 scoped_ptr<content::HostZoomMap::Subscription> sub = 1831 scoped_ptr<content::HostZoomMap::Subscription> sub =
1818 content::HostZoomMap::GetForBrowserContext( 1832 content::HostZoomMap::GetForBrowserContext(
1819 browser()->profile())->AddZoomLevelChangedCallback(callback); 1833 browser()->profile())->AddZoomLevelChangedCallback(callback);
1820 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); 1834 chrome::Zoom(browser(), content::PAGE_ZOOM_IN);
1821 loop_runner->Run(); 1835 loop_runner->Run();
1822 sub.reset(); 1836 sub.reset();
1823 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); 1837 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 110);
1824 EXPECT_TRUE(enable_plus); 1838 EXPECT_TRUE(enable_plus);
1825 EXPECT_TRUE(enable_minus); 1839 EXPECT_TRUE(enable_minus);
1826 } 1840 }
1827 1841
1828 { 1842 {
1829 scoped_refptr<content::MessageLoopRunner> loop_runner( 1843 scoped_refptr<content::MessageLoopRunner> loop_runner(
1830 new content::MessageLoopRunner); 1844 new content::MessageLoopRunner);
1831 content::HostZoomMap::ZoomLevelChangedCallback callback( 1845 content::HostZoomMap::ZoomLevelChangedCallback callback(
1832 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); 1846 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure()));
1833 scoped_ptr<content::HostZoomMap::Subscription> sub = 1847 scoped_ptr<content::HostZoomMap::Subscription> sub =
1834 content::HostZoomMap::GetForBrowserContext( 1848 content::HostZoomMap::GetForBrowserContext(
1835 browser()->profile())->AddZoomLevelChangedCallback(callback); 1849 browser()->profile())->AddZoomLevelChangedCallback(callback);
1836 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); 1850 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET);
1837 loop_runner->Run(); 1851 loop_runner->Run();
1838 sub.reset(); 1852 sub.reset();
1839 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100); 1853 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 100);
1840 EXPECT_TRUE(enable_plus); 1854 EXPECT_TRUE(enable_plus);
1841 EXPECT_TRUE(enable_minus); 1855 EXPECT_TRUE(enable_minus);
1842 } 1856 }
1843 1857
1844 { 1858 {
1845 scoped_refptr<content::MessageLoopRunner> loop_runner( 1859 scoped_refptr<content::MessageLoopRunner> loop_runner(
1846 new content::MessageLoopRunner); 1860 new content::MessageLoopRunner);
1847 content::HostZoomMap::ZoomLevelChangedCallback callback( 1861 content::HostZoomMap::ZoomLevelChangedCallback callback(
1848 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); 1862 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure()));
1849 scoped_ptr<content::HostZoomMap::Subscription> sub = 1863 scoped_ptr<content::HostZoomMap::Subscription> sub =
1850 content::HostZoomMap::GetForBrowserContext( 1864 content::HostZoomMap::GetForBrowserContext(
1851 browser()->profile())->AddZoomLevelChangedCallback(callback); 1865 browser()->profile())->AddZoomLevelChangedCallback(callback);
1852 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); 1866 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT);
1853 loop_runner->Run(); 1867 loop_runner->Run();
1854 sub.reset(); 1868 sub.reset();
1855 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90); 1869 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 90);
1856 EXPECT_TRUE(enable_plus); 1870 EXPECT_TRUE(enable_plus);
1857 EXPECT_TRUE(enable_minus); 1871 EXPECT_TRUE(enable_minus);
1858 } 1872 }
1859 1873
1860 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); 1874 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET);
1861 } 1875 }
1862 1876
1863 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { 1877 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) {
1864 ASSERT_TRUE(test_server()->Start()); 1878 ASSERT_TRUE(test_server()->Start());
1865 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 1879 host_resolver()->AddRule("www.example.com", "127.0.0.1");
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 #endif 2702 #endif
2689 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2703 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2690 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2704 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2691 gfx::Size exp_final_size(initial_wcv_size); 2705 gfx::Size exp_final_size(initial_wcv_size);
2692 exp_final_size.Enlarge(wcv_resize_insets.width(), 2706 exp_final_size.Enlarge(wcv_resize_insets.width(),
2693 wcv_resize_insets.height() + height_inset); 2707 wcv_resize_insets.height() + height_inset);
2694 EXPECT_EQ(exp_final_size, 2708 EXPECT_EQ(exp_final_size,
2695 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2709 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2696 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); 2710 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size());
2697 } 2711 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698