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

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: Add event manager for manual zoom events. 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 1788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 1799
1800 } // namespace 1800 } // namespace
1801 1801
1802 #if defined(OS_WIN) 1802 #if defined(OS_WIN)
1803 // Flakes regularly on Windows XP 1803 // Flakes regularly on Windows XP
1804 // http://crbug.com/146040 1804 // http://crbug.com/146040
1805 #define MAYBE_PageZoom DISABLED_PageZoom 1805 #define MAYBE_PageZoom DISABLED_PageZoom
1806 #else 1806 #else
1807 #define MAYBE_PageZoom PageZoom 1807 #define MAYBE_PageZoom PageZoom
1808 #endif 1808 #endif
1809
1810 namespace {
Devlin 2014/06/16 19:04:49 nit: The function is long enough that there should
wjmaclean 2014/06/18 19:03:54 Done.
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 }
Devlin 2014/06/16 19:04:49 bracket indentation is off.
wjmaclean 2014/06/18 19:03:54 Done.
1819 } // namespace
1820
1809 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { 1821 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) {
1810 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 1822 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
1811 bool enable_plus, enable_minus; 1823 bool enable_plus, enable_minus;
1812 1824
1813 { 1825 {
1814 scoped_refptr<content::MessageLoopRunner> loop_runner( 1826 scoped_refptr<content::MessageLoopRunner> loop_runner(
1815 new content::MessageLoopRunner); 1827 new content::MessageLoopRunner);
1816 content::HostZoomMap::ZoomLevelChangedCallback callback( 1828 content::HostZoomMap::ZoomLevelChangedCallback callback(
1817 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); 1829 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure()));
1818 scoped_ptr<content::HostZoomMap::Subscription> sub = 1830 scoped_ptr<content::HostZoomMap::Subscription> sub =
1819 content::HostZoomMap::GetForBrowserContext( 1831 content::HostZoomMap::GetForBrowserContext(
1820 browser()->profile())->AddZoomLevelChangedCallback(callback); 1832 browser()->profile())->AddZoomLevelChangedCallback(callback);
1821 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); 1833 chrome::Zoom(browser(), content::PAGE_ZOOM_IN);
1822 loop_runner->Run(); 1834 loop_runner->Run();
1823 sub.reset(); 1835 sub.reset();
1824 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); 1836 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 110);
1825 EXPECT_TRUE(enable_plus); 1837 EXPECT_TRUE(enable_plus);
1826 EXPECT_TRUE(enable_minus); 1838 EXPECT_TRUE(enable_minus);
1827 } 1839 }
1828 1840
1829 { 1841 {
1830 scoped_refptr<content::MessageLoopRunner> loop_runner( 1842 scoped_refptr<content::MessageLoopRunner> loop_runner(
1831 new content::MessageLoopRunner); 1843 new content::MessageLoopRunner);
1832 content::HostZoomMap::ZoomLevelChangedCallback callback( 1844 content::HostZoomMap::ZoomLevelChangedCallback callback(
1833 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); 1845 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure()));
1834 scoped_ptr<content::HostZoomMap::Subscription> sub = 1846 scoped_ptr<content::HostZoomMap::Subscription> sub =
1835 content::HostZoomMap::GetForBrowserContext( 1847 content::HostZoomMap::GetForBrowserContext(
1836 browser()->profile())->AddZoomLevelChangedCallback(callback); 1848 browser()->profile())->AddZoomLevelChangedCallback(callback);
1837 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); 1849 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET);
1838 loop_runner->Run(); 1850 loop_runner->Run();
1839 sub.reset(); 1851 sub.reset();
1840 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100); 1852 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 100);
1841 EXPECT_TRUE(enable_plus); 1853 EXPECT_TRUE(enable_plus);
1842 EXPECT_TRUE(enable_minus); 1854 EXPECT_TRUE(enable_minus);
1843 } 1855 }
1844 1856
1845 { 1857 {
1846 scoped_refptr<content::MessageLoopRunner> loop_runner( 1858 scoped_refptr<content::MessageLoopRunner> loop_runner(
1847 new content::MessageLoopRunner); 1859 new content::MessageLoopRunner);
1848 content::HostZoomMap::ZoomLevelChangedCallback callback( 1860 content::HostZoomMap::ZoomLevelChangedCallback callback(
1849 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); 1861 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure()));
1850 scoped_ptr<content::HostZoomMap::Subscription> sub = 1862 scoped_ptr<content::HostZoomMap::Subscription> sub =
1851 content::HostZoomMap::GetForBrowserContext( 1863 content::HostZoomMap::GetForBrowserContext(
1852 browser()->profile())->AddZoomLevelChangedCallback(callback); 1864 browser()->profile())->AddZoomLevelChangedCallback(callback);
1853 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); 1865 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT);
1854 loop_runner->Run(); 1866 loop_runner->Run();
1855 sub.reset(); 1867 sub.reset();
1856 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90); 1868 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 90);
1857 EXPECT_TRUE(enable_plus); 1869 EXPECT_TRUE(enable_plus);
1858 EXPECT_TRUE(enable_minus); 1870 EXPECT_TRUE(enable_minus);
1859 } 1871 }
1860 1872
1861 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); 1873 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET);
1862 } 1874 }
1863 1875
1864 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { 1876 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) {
1865 ASSERT_TRUE(test_server()->Start()); 1877 ASSERT_TRUE(test_server()->Start());
1866 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 1878 host_resolver()->AddRule("www.example.com", "127.0.0.1");
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 #endif 2702 #endif
2691 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2703 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2692 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2704 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2693 gfx::Size exp_final_size(initial_wcv_size); 2705 gfx::Size exp_final_size(initial_wcv_size);
2694 exp_final_size.Enlarge(wcv_resize_insets.width(), 2706 exp_final_size.Enlarge(wcv_resize_insets.width(),
2695 wcv_resize_insets.height() + height_inset); 2707 wcv_resize_insets.height() + height_inset);
2696 EXPECT_EQ(exp_final_size, 2708 EXPECT_EQ(exp_final_size,
2697 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2709 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2698 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); 2710 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size());
2699 } 2711 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698