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

Side by Side Diff: components/test_runner/test_runner.cc

Issue 1571833002: Add popup layout tests with device scale factor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/test_runner/test_runner.h" 5 #include "components/test_runner/test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <limits> 8 #include <limits>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
14 #include "build/build_config.h" 16 #include "build/build_config.h"
15 #include "components/test_runner/mock_credential_manager_client.h" 17 #include "components/test_runner/mock_credential_manager_client.h"
16 #include "components/test_runner/mock_web_speech_recognizer.h" 18 #include "components/test_runner/mock_web_speech_recognizer.h"
17 #include "components/test_runner/test_interfaces.h" 19 #include "components/test_runner/test_interfaces.h"
18 #include "components/test_runner/test_preferences.h" 20 #include "components/test_runner/test_preferences.h"
19 #include "components/test_runner/web_content_settings.h" 21 #include "components/test_runner/web_content_settings.h"
20 #include "components/test_runner/web_test_delegate.h" 22 #include "components/test_runner/web_test_delegate.h"
21 #include "components/test_runner/web_test_proxy.h" 23 #include "components/test_runner/web_test_proxy.h"
22 #include "gin/arguments.h" 24 #include "gin/arguments.h"
(...skipping 26 matching lines...) Expand all
49 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" 51 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h"
50 #include "third_party/WebKit/public/web/WebSettings.h" 52 #include "third_party/WebKit/public/web/WebSettings.h"
51 #include "third_party/WebKit/public/web/WebSurroundingText.h" 53 #include "third_party/WebKit/public/web/WebSurroundingText.h"
52 #include "third_party/WebKit/public/web/WebView.h" 54 #include "third_party/WebKit/public/web/WebView.h"
53 #include "third_party/skia/include/core/SkBitmap.h" 55 #include "third_party/skia/include/core/SkBitmap.h"
54 #include "third_party/skia/include/core/SkCanvas.h" 56 #include "third_party/skia/include/core/SkCanvas.h"
55 #include "ui/gfx/geometry/rect.h" 57 #include "ui/gfx/geometry/rect.h"
56 #include "ui/gfx/geometry/rect_f.h" 58 #include "ui/gfx/geometry/rect_f.h"
57 #include "ui/gfx/geometry/size.h" 59 #include "ui/gfx/geometry/size.h"
58 #include "ui/gfx/skia_util.h" 60 #include "ui/gfx/skia_util.h"
61 #include "ui/gfx/switches.h"
59 62
60 #if defined(__linux__) || defined(ANDROID) 63 #if defined(__linux__) || defined(ANDROID)
61 #include "third_party/WebKit/public/web/linux/WebFontRendering.h" 64 #include "third_party/WebKit/public/web/linux/WebFontRendering.h"
62 #endif 65 #endif
63 66
64 using namespace blink; 67 using namespace blink;
65 68
66 namespace test_runner { 69 namespace test_runner {
67 70
68 namespace { 71 namespace {
69 72
70 WebString V8StringToWebString(v8::Local<v8::String> v8_str) { 73 WebString V8StringToWebString(v8::Local<v8::String> v8_str) {
71 int length = v8_str->Utf8Length() + 1; 74 int length = v8_str->Utf8Length() + 1;
72 scoped_ptr<char[]> chars(new char[length]); 75 scoped_ptr<char[]> chars(new char[length]);
73 v8_str->WriteUtf8(chars.get(), length); 76 v8_str->WriteUtf8(chars.get(), length);
74 return WebString::fromUTF8(chars.get()); 77 return WebString::fromUTF8(chars.get());
75 } 78 }
76 79
80 double GetDefaultDeviceScaleFactor() {
81 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
82 if (command_line->HasSwitch(switches::kForceDeviceScaleFactor)) {
83 double scale;
84 std::string value =
85 command_line->GetSwitchValueASCII(switches::kForceDeviceScaleFactor);
86 if (base::StringToDouble(value, &scale))
87 return scale;
88 }
89 return 1.f;
90 }
91
77 class HostMethodTask : public WebMethodTask<TestRunner> { 92 class HostMethodTask : public WebMethodTask<TestRunner> {
78 public: 93 public:
79 typedef void (TestRunner::*CallbackMethodType)(); 94 typedef void (TestRunner::*CallbackMethodType)();
80 HostMethodTask(TestRunner* object, CallbackMethodType callback) 95 HostMethodTask(TestRunner* object, CallbackMethodType callback)
81 : WebMethodTask<TestRunner>(object), callback_(callback) {} 96 : WebMethodTask<TestRunner>(object), callback_(callback) {}
82 97
83 void RunIfValid() override { (object_->*callback_)(); } 98 void RunIfValid() override { (object_->*callback_)(); }
84 99
85 private: 100 private:
86 CallbackMethodType callback_; 101 CallbackMethodType callback_;
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 1709
1695 WebSecurityPolicy::resetOriginAccessWhitelists(); 1710 WebSecurityPolicy::resetOriginAccessWhitelists();
1696 #if defined(__linux__) || defined(ANDROID) 1711 #if defined(__linux__) || defined(ANDROID)
1697 WebFontRendering::setSubpixelPositioning(false); 1712 WebFontRendering::setSubpixelPositioning(false);
1698 #endif 1713 #endif
1699 1714
1700 if (delegate_) { 1715 if (delegate_) {
1701 // Reset the default quota for each origin to 5MB 1716 // Reset the default quota for each origin to 5MB
1702 delegate_->SetDatabaseQuota(5 * 1024 * 1024); 1717 delegate_->SetDatabaseQuota(5 * 1024 * 1024);
1703 delegate_->SetDeviceColorProfile("reset"); 1718 delegate_->SetDeviceColorProfile("reset");
1704 delegate_->SetDeviceScaleFactor(1); 1719 delegate_->SetDeviceScaleFactor(GetDefaultDeviceScaleFactor());
1705 delegate_->SetAcceptAllCookies(false); 1720 delegate_->SetAcceptAllCookies(false);
1706 delegate_->SetLocale(""); 1721 delegate_->SetLocale("");
1707 delegate_->UseUnfortunateSynchronousResizeMode(false); 1722 delegate_->UseUnfortunateSynchronousResizeMode(false);
1708 delegate_->DisableAutoResizeMode(WebSize()); 1723 delegate_->DisableAutoResizeMode(WebSize());
1709 delegate_->DeleteAllCookies(); 1724 delegate_->DeleteAllCookies();
1710 delegate_->ResetScreenOrientation(); 1725 delegate_->ResetScreenOrientation();
1711 delegate_->SetBluetoothMockDataSet(""); 1726 delegate_->SetBluetoothMockDataSet("");
1712 delegate_->ClearGeofencingMockProvider(); 1727 delegate_->ClearGeofencingMockProvider();
1713 delegate_->ResetPermissions(); 1728 delegate_->ResetPermissions();
1714 ResetBatteryStatus(); 1729 ResetBatteryStatus();
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
3173 } 3188 }
3174 3189
3175 void TestRunner::DidLosePointerLockInternal() { 3190 void TestRunner::DidLosePointerLockInternal() {
3176 bool was_locked = pointer_locked_; 3191 bool was_locked = pointer_locked_;
3177 pointer_locked_ = false; 3192 pointer_locked_ = false;
3178 if (was_locked) 3193 if (was_locked)
3179 web_view_->didLosePointerLock(); 3194 web_view_->didLosePointerLock();
3180 } 3195 }
3181 3196
3182 } // namespace test_runner 3197 } // namespace test_runner
OLDNEW
« no previous file with comments | « components/html_viewer/web_test_delegate_impl.cc ('k') | components/test_runner/web_test_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698