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

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: Address comments. 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 {
1811
1812 int GetZoomPercent(const content::WebContents* contents,
1813 bool* enable_plus,
1814 bool* enable_minus) {
1815 int percent = ZoomController::FromWebContents(contents)->GetZoomPercent();
1816 *enable_plus = percent < contents->GetMaximumZoomPercent();
1817 *enable_minus = percent > contents->GetMinimumZoomPercent();
1818 return percent;
1819 }
1820
1821 } // namespace
1822
1809 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) { 1823 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_PageZoom) {
1810 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); 1824 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents();
1811 bool enable_plus, enable_minus; 1825 bool enable_plus, enable_minus;
1812 1826
1813 { 1827 {
1814 scoped_refptr<content::MessageLoopRunner> loop_runner( 1828 scoped_refptr<content::MessageLoopRunner> loop_runner(
1815 new content::MessageLoopRunner); 1829 new content::MessageLoopRunner);
1816 content::HostZoomMap::ZoomLevelChangedCallback callback( 1830 content::HostZoomMap::ZoomLevelChangedCallback callback(
1817 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); 1831 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure()));
1818 scoped_ptr<content::HostZoomMap::Subscription> sub = 1832 scoped_ptr<content::HostZoomMap::Subscription> sub =
1819 content::HostZoomMap::GetForBrowserContext( 1833 content::HostZoomMap::GetForBrowserContext(
1820 browser()->profile())->AddZoomLevelChangedCallback(callback); 1834 browser()->profile())->AddZoomLevelChangedCallback(callback);
1821 chrome::Zoom(browser(), content::PAGE_ZOOM_IN); 1835 chrome::Zoom(browser(), content::PAGE_ZOOM_IN);
1822 loop_runner->Run(); 1836 loop_runner->Run();
1823 sub.reset(); 1837 sub.reset();
1824 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 110); 1838 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 110);
1825 EXPECT_TRUE(enable_plus); 1839 EXPECT_TRUE(enable_plus);
1826 EXPECT_TRUE(enable_minus); 1840 EXPECT_TRUE(enable_minus);
1827 } 1841 }
1828 1842
1829 { 1843 {
1830 scoped_refptr<content::MessageLoopRunner> loop_runner( 1844 scoped_refptr<content::MessageLoopRunner> loop_runner(
1831 new content::MessageLoopRunner); 1845 new content::MessageLoopRunner);
1832 content::HostZoomMap::ZoomLevelChangedCallback callback( 1846 content::HostZoomMap::ZoomLevelChangedCallback callback(
1833 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); 1847 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure()));
1834 scoped_ptr<content::HostZoomMap::Subscription> sub = 1848 scoped_ptr<content::HostZoomMap::Subscription> sub =
1835 content::HostZoomMap::GetForBrowserContext( 1849 content::HostZoomMap::GetForBrowserContext(
1836 browser()->profile())->AddZoomLevelChangedCallback(callback); 1850 browser()->profile())->AddZoomLevelChangedCallback(callback);
1837 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); 1851 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET);
1838 loop_runner->Run(); 1852 loop_runner->Run();
1839 sub.reset(); 1853 sub.reset();
1840 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 100); 1854 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 100);
1841 EXPECT_TRUE(enable_plus); 1855 EXPECT_TRUE(enable_plus);
1842 EXPECT_TRUE(enable_minus); 1856 EXPECT_TRUE(enable_minus);
1843 } 1857 }
1844 1858
1845 { 1859 {
1846 scoped_refptr<content::MessageLoopRunner> loop_runner( 1860 scoped_refptr<content::MessageLoopRunner> loop_runner(
1847 new content::MessageLoopRunner); 1861 new content::MessageLoopRunner);
1848 content::HostZoomMap::ZoomLevelChangedCallback callback( 1862 content::HostZoomMap::ZoomLevelChangedCallback callback(
1849 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure())); 1863 base::Bind(&OnZoomLevelChanged, loop_runner->QuitClosure()));
1850 scoped_ptr<content::HostZoomMap::Subscription> sub = 1864 scoped_ptr<content::HostZoomMap::Subscription> sub =
1851 content::HostZoomMap::GetForBrowserContext( 1865 content::HostZoomMap::GetForBrowserContext(
1852 browser()->profile())->AddZoomLevelChangedCallback(callback); 1866 browser()->profile())->AddZoomLevelChangedCallback(callback);
1853 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT); 1867 chrome::Zoom(browser(), content::PAGE_ZOOM_OUT);
1854 loop_runner->Run(); 1868 loop_runner->Run();
1855 sub.reset(); 1869 sub.reset();
1856 EXPECT_EQ(contents->GetZoomPercent(&enable_plus, &enable_minus), 90); 1870 EXPECT_EQ(GetZoomPercent(contents, &enable_plus, &enable_minus), 90);
1857 EXPECT_TRUE(enable_plus); 1871 EXPECT_TRUE(enable_plus);
1858 EXPECT_TRUE(enable_minus); 1872 EXPECT_TRUE(enable_minus);
1859 } 1873 }
1860 1874
1861 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET); 1875 chrome::Zoom(browser(), content::PAGE_ZOOM_RESET);
1862 } 1876 }
1863 1877
1864 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) { 1878 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCommandDisable) {
1865 ASSERT_TRUE(test_server()->Start()); 1879 ASSERT_TRUE(test_server()->Start());
1866 host_resolver()->AddRule("www.example.com", "127.0.0.1"); 1880 host_resolver()->AddRule("www.example.com", "127.0.0.1");
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
2690 #endif 2704 #endif
2691 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); 2705 EXPECT_EQ(exp_commit_size, rwhv_commit_size2);
2692 EXPECT_EQ(exp_commit_size, wcv_commit_size2); 2706 EXPECT_EQ(exp_commit_size, wcv_commit_size2);
2693 gfx::Size exp_final_size(initial_wcv_size); 2707 gfx::Size exp_final_size(initial_wcv_size);
2694 exp_final_size.Enlarge(wcv_resize_insets.width(), 2708 exp_final_size.Enlarge(wcv_resize_insets.width(),
2695 wcv_resize_insets.height() + height_inset); 2709 wcv_resize_insets.height() + height_inset);
2696 EXPECT_EQ(exp_final_size, 2710 EXPECT_EQ(exp_final_size,
2697 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); 2711 web_contents->GetRenderWidgetHostView()->GetViewBounds().size());
2698 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size()); 2712 EXPECT_EQ(exp_final_size, web_contents->GetContainerBounds().size());
2699 } 2713 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698