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

Side by Side Diff: build/android/devil/utils/geometry_test.py

Issue 1770943003: [Android] Remove chromium version of devil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
« no previous file with comments | « build/android/devil/utils/geometry.py ('k') | build/android/devil/utils/host_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Tests for the geometry module."""
6
7 import unittest
8
9 from devil.utils import geometry as g
10
11
12 class PointTest(unittest.TestCase):
13 def testStr(self):
14 p = g.Point(1, 2)
15 self.assertEquals(str(p), '(1, 2)')
16
17 def testAdd(self):
18 p = g.Point(1, 2)
19 q = g.Point(3, 4)
20 r = g.Point(4, 6)
21 self.assertEquals(p + q, r)
22
23 def testAdd_TypeErrorWithInvalidOperands(self):
24 # pylint: disable=pointless-statement
25 p = g.Point(1, 2)
26 with self.assertRaises(TypeError):
27 p + 4 # Can't add point and scalar.
28 with self.assertRaises(TypeError):
29 4 + p # Can't add scalar and point.
30
31 def testMult(self):
32 p = g.Point(1, 2)
33 r = g.Point(2, 4)
34 self.assertEquals(2 * p, r) # Multiply by scalar on the left.
35
36 def testMult_TypeErrorWithInvalidOperands(self):
37 # pylint: disable=pointless-statement
38 p = g.Point(1, 2)
39 q = g.Point(2, 4)
40 with self.assertRaises(TypeError):
41 p * q # Can't multiply points.
42 with self.assertRaises(TypeError):
43 p * 4 # Can't multiply by a scalar on the right.
44
45 class RectangleTest(unittest.TestCase):
46 def testStr(self):
47 r = g.Rectangle(g.Point(0, 1), g.Point(2, 3))
48 self.assertEquals(str(r), '[(0, 1), (2, 3)]')
49
50 def testCenter(self):
51 r = g.Rectangle(g.Point(0, 1), g.Point(2, 3))
52 c = g.Point(1, 2)
53 self.assertEquals(r.center, c)
54
55 def testFromJson(self):
56 r1 = g.Rectangle(g.Point(0, 1), g.Point(2, 3))
57 r2 = g.Rectangle.FromDict({'top': 1, 'left': 0, 'bottom': 3, 'right': 2})
58 self.assertEquals(r1, r2)
OLDNEW
« no previous file with comments | « build/android/devil/utils/geometry.py ('k') | build/android/devil/utils/host_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698