Exemple #1
0
    def testCanAddLocationToRegion(self):

        region = Region(100, 100, 1, 1)

        # Check that initialized properly
        self.assertEqual(region.getX(), 100)
        self.assertEqual(region.getY(), 100)
        self.assertEqual(region.getW(), 1)
        self.assertEqual(region.getH(), 1)

        region = region.add(Location(50, 50))

        # X,Y Should have changed to 50
        self.assertEqual(region.getX(), 50)
        self.assertEqual(region.getY(), 50)

        # W,H should have changed to 50
        self.assertEqual(region.getW(), 51)
        self.assertEqual(region.getH(), 51)

        region = region.add(Location(200, 50))

        # Width/Height should have changed to 200/200
        self.assertEqual(region.getX(), 50)
        self.assertEqual(region.getY(), 50)
        self.assertEqual(region.getW(), 150)
        self.assertEqual(region.getH(), 51)

        region = region.add(Location(200, 200))

        # Width/Height should have changed to 200/200
        self.assertEqual(region.getX(), 50)
        self.assertEqual(region.getY(), 50)
        self.assertEqual(region.getW(), 150)
        self.assertEqual(region.getH(), 150)
Exemple #2
0
    def testCanLimitRegion(self):

        region = Region(50, 50, 400, 400).limit(Region(150, 100, 150, 25))
        self.assertEqual(region.getX(), 150)
        self.assertEqual(region.getY(), 100)
        self.assertEqual(region.getW(), 150)
        self.assertEqual(region.getH(), 25)

        region = Region(100, 100, 200, 200).limit(Region(50, 50, 400, 400))
        self.assertEqual(region.getX(), 100)
        self.assertEqual(region.getY(), 100)
        self.assertEqual(region.getW(), 200)
        self.assertEqual(region.getH(), 200)
 def testCanLimitRegion(self):
     
     region = Region(50,50,400,400).limit( Region(150,100,150,25) )
     self.assertEqual(region.getX(), 150)
     self.assertEqual(region.getY(), 100)
     self.assertEqual(region.getW(), 150)
     self.assertEqual(region.getH(), 25)
     
     region = Region(100,100,200,200).limit( Region(50,50,400,400) )
     self.assertEqual(region.getX(), 100)
     self.assertEqual(region.getY(), 100)
     self.assertEqual(region.getW(), 200)
     self.assertEqual(region.getH(), 200)
Exemple #4
0
    def testSetOffset(self):

        region = Region(100, 100, 100, 100)
        region = region.offset(Location(100, 100))

        self.assertEqual(region.getX(), 200)
        self.assertEqual(region.getY(), 200)
        self.assertEqual(region.getW(), 100)
        self.assertEqual(region.getH(), 100)
    def testSetOffset(self):
        
        region = Region(100,100,100,100)
        region = region.offset(Location(100,100))

        self.assertEqual(region.getX(), 200)
        self.assertEqual(region.getY(), 200)      
        self.assertEqual(region.getW(), 100)
        self.assertEqual(region.getH(), 100)      
Exemple #6
0
    def testRegionCanAddRegion(self):

        region = Region(100, 100, 100, 100)
        region = region.add(Region(100, 100, 200, 200))

        # Width/Height should have changed to 200/200
        self.assertEqual(region.getX(), 100)
        self.assertEqual(region.getY(), 100)
        self.assertEqual(region.getW(), 200)
        self.assertEqual(region.getH(), 200)
 def testRegionCanAddRegion(self):      
     
     region = Region(100,100,100,100)
     region = region.add(Region(100,100,200,200))
     
     # Width/Height should have changed to 200/200
     self.assertEqual(region.getX(), 100)
     self.assertEqual(region.getY(), 100)
     self.assertEqual(region.getW(), 200)
     self.assertEqual(region.getH(), 200)
 def testCreateRegionFromList(self):      
     
     regions = [Region(50,50,50,50), Region(200,50,50,50), Region(200,50,50,50), Region(200,200,50,50)] 
     
     region = Region(regions)
     
     # Width/Height should have changed to 200/200
     self.assertEqual(region.getX(), 50)
     self.assertEqual(region.getY(), 50)
     self.assertEqual(region.getW(), 200)
     self.assertEqual(region.getH(), 200)
    def testCanAddLocationToRegion(self):
        
        region = Region(100,100,1,1)
        
        # Check that initialized properly
        self.assertEqual(region.getX(), 100)
        self.assertEqual(region.getY(), 100)
        self.assertEqual(region.getW(), 1)
        self.assertEqual(region.getH(), 1)

        region = region.add(Location(50,50))
        
        # X,Y Should have changed to 50
        self.assertEqual(region.getX(), 50)
        self.assertEqual(region.getY(), 50)
        
        # W,H should have changed to 50
        self.assertEqual(region.getW(), 51)
        self.assertEqual(region.getH(), 51)
        
        region = region.add(Location(200,50))

        # Width/Height should have changed to 200/200
        self.assertEqual(region.getX(), 50)
        self.assertEqual(region.getY(), 50)
        self.assertEqual(region.getW(), 150)
        self.assertEqual(region.getH(), 51)
        
        
        region = region.add(Location(200,200))
        
        # Width/Height should have changed to 200/200
        self.assertEqual(region.getX(), 50)
        self.assertEqual(region.getY(), 50)
        self.assertEqual(region.getW(), 150)
        self.assertEqual(region.getH(), 150)
Exemple #10
0
    def testCreateRegionFromList(self):

        regions = [
            Region(50, 50, 50, 50),
            Region(200, 50, 50, 50),
            Region(200, 50, 50, 50),
            Region(200, 200, 50, 50)
        ]

        region = Region(regions)

        # Width/Height should have changed to 200/200
        self.assertEqual(region.getX(), 50)
        self.assertEqual(region.getY(), 50)
        self.assertEqual(region.getW(), 200)
        self.assertEqual(region.getH(), 200)