Use the correct ratio to scale vnc display to fit into user's monitor.

Bug: 117634012
Test: atest acloud_test && acloud create to check the display of vnc client.
Change-Id: I825b82a32455c3dff3700757aaadc49343f2405e
diff --git a/internal/lib/utils_test.py b/internal/lib/utils_test.py
index 9d62077..cdb18ef 100644
--- a/internal/lib/utils_test.py
+++ b/internal/lib/utils_test.py
@@ -22,6 +22,7 @@
 import subprocess
 import tempfile
 import time
+import Tkinter
 
 import unittest
 import mock
@@ -244,6 +245,40 @@
                                                  enable_choose_all=True),
                          answer_list)
 
+    @mock.patch.object(Tkinter.Tk, "winfo_screenwidth")
+    @mock.patch.object(Tkinter.Tk, "winfo_screenheight")
+    def testCalculateVNCScreenRatio(self, mock_screenheight, mock_screenwidth):
+        """Test Calculating the scale ratio of VNC display."""
+
+        # Get scale-down ratio if screen height is smaller than AVD height.
+        mock_screenheight.return_value = 800
+        mock_screenwidth.return_value = 1200
+        avd_h = 1920
+        avd_w = 1080
+        self.assertEqual(utils.CalculateVNCScreenRatio(avd_w, avd_h), 0.4)
+
+        # Get scale-down ratio if screen width is smaller than AVD width.
+        mock_screenheight.return_value = 800
+        mock_screenwidth.return_value = 1200
+        avd_h = 900
+        avd_w = 1920
+        self.assertEqual(utils.CalculateVNCScreenRatio(avd_w, avd_h), 0.6)
+
+        # Scale ratio = 1 if screen is larger than AVD.
+        mock_screenheight.return_value = 1080
+        mock_screenwidth.return_value = 1920
+        avd_h = 800
+        avd_w = 1280
+        self.assertEqual(utils.CalculateVNCScreenRatio(avd_w, avd_h), 1)
+
+        # Get the scale if ratio of width is smaller than the
+        # ratio of height.
+        mock_screenheight.return_value = 1200
+        mock_screenwidth.return_value = 800
+        avd_h = 1920
+        avd_w = 1080
+        self.assertEqual(utils.CalculateVNCScreenRatio(avd_w, avd_h), 0.6)
+
 
 if __name__ == "__main__":
     unittest.main()