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

Unified Diff: remoting/webapp/unittests/client_session_unittest.js

Issue 804783002: Improve DPI matching & scaling logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit-tests! Created 5 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 side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/unittests/client_session_unittest.js
diff --git a/remoting/webapp/unittests/client_session_unittest.js b/remoting/webapp/unittests/client_session_unittest.js
new file mode 100644
index 0000000000000000000000000000000000000000..f8e842850dcc0ab570e316065d9b00d197ec2cd9
--- /dev/null
+++ b/remoting/webapp/unittests/client_session_unittest.js
@@ -0,0 +1,102 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+(function() {
+
+'use strict';
+
+module('client_session');
+
+function size(width, height) {
+ return {width: width, height: height};
+}
+
+function dpi(x, y) {
+ return {x: x, y: y};
+}
+
+test('choosePluginSize() chooses sensible sizes',
+ function() {
+ // Client and host w/ same DPI.
Jamie 2015/02/04 23:18:30 I think these test cases need descriptions to make
Wez 2015/02/06 01:29:43 Yeah, I think splitting into a set of distinct tes
+ var pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 1.0, size(640, 480), dpi(96, 96), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(640, 480));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(1280, 900), 1.0, size(640, 480), dpi(96, 96), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(640, 480));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(1280, 1024), 1.0, size(640, 480), dpi(96, 96), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(1280, 960));
+
+ // High DPI client, low DPI host.
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 450), 2.0, size(640, 480), dpi(96, 96), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(600, 450));
Jamie 2015/02/04 23:18:30 It took me a while to work out where the 600 came
Wez 2015/02/06 01:29:43 Acknowledged.
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 2.0, size(640, 480), dpi(96, 96), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(640, 480));
+
+ // High DPI host, low DPI client.
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 1.0, size(640, 480), dpi(192, 192), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(640, 480));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 1.0, size(1024, 768), dpi(192, 192), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(640, 480));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(1024, 768), 1.0, size(640, 480), dpi(192, 192), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(640, 480));
+
+ // High DPI host, high DPI client.
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 2.0, size(640, 480), dpi(192, 192), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(640, 480));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 2.0, size(1024, 768), dpi(192, 192), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(512, 384));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(1024, 768), 2.0, size(640, 480), dpi(192, 192), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(960, 720));
+
+ // 150% DPI host, high DPI client.
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 2.0, size(640, 480), dpi(144, 144), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(640, 480));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 2.0, size(1024, 768), dpi(144, 144), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(512, 384));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(1024, 768), 2.0, size(640, 480), dpi(144, 144), 1.0, false, true);
+ QUnit.deepEqual(pluginSize, size(960, 720));
+
+ // Shrink-to-fit disabled.
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 1.0, size(640, 480), dpi(96, 96), 1.0, false, false);
+ QUnit.deepEqual(pluginSize, size(640, 480));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(1280, 1024), 1.0, size(640, 480), dpi(96, 96), 1.0, false, false);
+ QUnit.deepEqual(pluginSize, size(1280, 960));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 1.0, size(1280, 1024), dpi(96, 96), 1.0, false, false);
+ QUnit.deepEqual(pluginSize, size(1280, 1024));
+
+ pluginSize = remoting.ClientSession.choosePluginSize(
+ size(640, 480), 2.0, size(1280, 1024), dpi(96, 96), 1.0, false, false);
+ QUnit.deepEqual(pluginSize, size(1280, 1024));
+
+ // Full-screen multi-monitor handling.
+});
+
+})();
« remoting/webapp/crd/js/client_session.js ('K') | « remoting/webapp/crd/js/client_session.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698