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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_browsertest.cc

Issue 293563002: GetScaleFactorForNativeView should return scale factor in float (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/message_loop/message_loop_proxy.h" 6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/browser/gpu/compositor_util.h" 9 #include "content/browser/gpu/compositor_util.h"
10 #include "content/browser/gpu/gpu_data_manager_impl.h" 10 #include "content/browser/gpu/gpu_data_manager_impl.h"
11 #include "content/browser/renderer_host/dip_util.h" 11 #include "content/browser/renderer_host/dip_util.h"
12 #include "content/browser/renderer_host/render_widget_host_impl.h" 12 #include "content/browser/renderer_host/render_widget_host_impl.h"
13 #include "content/browser/renderer_host/render_widget_host_view_base.h" 13 #include "content/browser/renderer_host/render_widget_host_view_base.h"
14 #include "content/public/browser/gpu_data_manager.h" 14 #include "content/public/browser/gpu_data_manager.h"
15 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
16 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 16 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/content_paths.h" 18 #include "content/public/common/content_paths.h"
19 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
20 #include "content/public/common/url_constants.h" 20 #include "content/public/common/url_constants.h"
21 #include "content/public/test/browser_test_utils.h" 21 #include "content/public/test/browser_test_utils.h"
22 #include "content/public/test/content_browser_test.h" 22 #include "content/public/test/content_browser_test.h"
23 #include "content/public/test/content_browser_test_utils.h" 23 #include "content/public/test/content_browser_test_utils.h"
24 #include "content/shell/browser/shell.h" 24 #include "content/shell/browser/shell.h"
25 #include "media/base/video_frame.h" 25 #include "media/base/video_frame.h"
26 #include "media/filters/skcanvas_video_renderer.h" 26 #include "media/filters/skcanvas_video_renderer.h"
27 #include "net/base/filename_util.h" 27 #include "net/base/filename_util.h"
28 #include "third_party/skia/include/core/SkBitmap.h" 28 #include "third_party/skia/include/core/SkBitmap.h"
29 #include "third_party/skia/include/core/SkCanvas.h" 29 #include "third_party/skia/include/core/SkCanvas.h"
30 #include "ui/base/layout.h"
30 #include "ui/base/ui_base_switches.h" 31 #include "ui/base/ui_base_switches.h"
31 #include "ui/gfx/size_conversions.h" 32 #include "ui/gfx/size_conversions.h"
32 #include "ui/gfx/switches.h" 33 #include "ui/gfx/switches.h"
33 #include "ui/gl/gl_switches.h" 34 #include "ui/gl/gl_switches.h"
34 35
35 #if defined(OS_MACOSX) 36 #if defined(OS_MACOSX)
36 #include "ui/gl/io_surface_support_mac.h" 37 #include "ui/gl/io_surface_support_mac.h"
37 #endif 38 #endif
38 39
39 #if defined(OS_WIN) 40 #if defined(OS_WIN)
40 #include "base/win/windows_version.h" 41 #include "base/win/windows_version.h"
41 #include "ui/gfx/win/dpi.h" 42 #include "ui/gfx/win/dpi.h"
42 #endif 43 #endif
43 44
44 namespace content { 45 namespace content {
45 namespace { 46 namespace {
46 47
47 // Convenience macro: Short-circuit a pass for the tests where platform support 48 // Convenience macro: Short-circuit a pass for the tests where platform support
48 // for forced-compositing mode (or disabled-compositing mode) is lacking. 49 // for forced-compositing mode (or disabled-compositing mode) is lacking.
49 #define SET_UP_SURFACE_OR_PASS_TEST(wait_message) \ 50 #define SET_UP_SURFACE_OR_PASS_TEST(wait_message) \
50 if (!SetUpSourceSurface(wait_message)) { \ 51 if (!SetUpSourceSurface(wait_message)) { \
51 LOG(WARNING) \ 52 LOG(WARNING) \
52 << ("Blindly passing this test: This platform does not support " \ 53 << ("Blindly passing this test: This platform does not support " \
53 "forced compositing (or forced-disabled compositing) mode."); \ 54 "forced compositing (or forced-disabled compositing) mode."); \
54 return; \ 55 return; \
55 } 56 }
56 57
57 // Convenience macro: Short-circuit a pass for platforms where setting up
58 // high-DPI fails.
59 #define PASS_TEST_IF_SCALE_FACTOR_NOT_SUPPORTED(factor) \
60 if (ui::GetScaleForScaleFactor( \
61 GetScaleFactorForView(GetRenderWidgetHostView())) != factor) { \
62 LOG(WARNING) << "Blindly passing this test: failed to set up " \
63 "scale factor: " << factor; \
64 return false; \
65 }
66
67 // Common base class for browser tests. This is subclassed twice: Once to test 58 // Common base class for browser tests. This is subclassed twice: Once to test
68 // the browser in forced-compositing mode, and once to test with compositing 59 // the browser in forced-compositing mode, and once to test with compositing
69 // mode disabled. 60 // mode disabled.
70 class RenderWidgetHostViewBrowserTest : public ContentBrowserTest { 61 class RenderWidgetHostViewBrowserTest : public ContentBrowserTest {
71 public: 62 public:
72 RenderWidgetHostViewBrowserTest() 63 RenderWidgetHostViewBrowserTest()
73 : frame_size_(400, 300), 64 : frame_size_(400, 300),
74 callback_invoke_count_(0), 65 callback_invoke_count_(0),
75 frames_captured_(0) {} 66 frames_captured_(0) {}
76 67
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 #if defined(OS_WIN) 794 #if defined(OS_WIN)
804 gfx::ForceHighDPISupportForTesting(scale()); 795 gfx::ForceHighDPISupportForTesting(scale());
805 gfx::EnableHighDPISupport(); 796 gfx::EnableHighDPISupport();
806 #endif 797 #endif
807 } 798 }
808 799
809 float scale() const { return kScale; } 800 float scale() const { return kScale; }
810 801
811 private: 802 private:
812 virtual bool ShouldContinueAfterTestURLLoad() OVERRIDE { 803 virtual bool ShouldContinueAfterTestURLLoad() OVERRIDE {
813 PASS_TEST_IF_SCALE_FACTOR_NOT_SUPPORTED(scale()); 804 // Short-circuit a pass for platforms where setting up high-DPI fails.
805 if (ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(
806 GetScaleFactorForView(GetRenderWidgetHostView()))) != scale()) {
807 LOG(WARNING) << "Blindly passing this test: failed to set up "
808 "scale factor: " << scale();
809 return false;
810 }
814 return true; 811 return true;
815 } 812 }
816 813
817 const float kScale; 814 const float kScale;
818 815
819 DISALLOW_COPY_AND_ASSIGN(CompositingRenderWidgetHostViewTabCaptureHighDPI); 816 DISALLOW_COPY_AND_ASSIGN(CompositingRenderWidgetHostViewTabCaptureHighDPI);
820 }; 817 };
821 818
822 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewTabCaptureHighDPI, 819 IN_PROC_BROWSER_TEST_P(CompositingRenderWidgetHostViewTabCaptureHighDPI,
823 CopyFromCompositingSurface) { 820 CopyFromCompositingSurface) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 CompositingRenderWidgetHostViewBrowserTestTabCapture, 865 CompositingRenderWidgetHostViewBrowserTestTabCapture,
869 testing::ValuesIn(kAllCompositingModes)); 866 testing::ValuesIn(kAllCompositingModes));
870 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing, 867 INSTANTIATE_TEST_CASE_P(GLAndSoftwareCompositing,
871 CompositingRenderWidgetHostViewTabCaptureHighDPI, 868 CompositingRenderWidgetHostViewTabCaptureHighDPI,
872 testing::ValuesIn(kAllCompositingModes)); 869 testing::ValuesIn(kAllCompositingModes));
873 870
874 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) 871 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
875 872
876 } // namespace 873 } // namespace
877 } // namespace content 874 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | content/browser/renderer_host/render_widget_host_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698