Exemplo n.º 1
0
    def invalid_objects(self, stubs):
        """Set up the following base situation.

             0, 0                         300, 0
              ##############################
              #                            #
         0,10 # iframe  100,10             #
              #**********                  #
              #* e      * elems[0]: 10, 10 in iframe (visible)
              #*        *                  #
              #*        *                  #
              #**********                  #
        0,110 #.        .100,110           #
              #.        .                  #
              #. e      . elems[2]: 20,150 in iframe (not visible)
              #..........                  #
              ##############################
            300, 0                         300, 300

        Returns an Objects object with frame/iframe/elems attributes.
        """
        frame = stubs.FakeWebFrame(QRect(0, 0, 300, 300))
        iframe = stubs.FakeWebFrame(QRect(0, 10, 100, 100), parent=frame)
        assert frame.geometry().contains(iframe.geometry())

        elems = [
            get_webelem(QRect(10, 10, 0, 0), iframe),
            get_webelem(QRect(20, 150, 0, 0), iframe),
        ]
        for e in elems:
            assert not e.geometry().isValid()

        return self.Objects(frame=frame, iframe=iframe, elems=elems)
Exemplo n.º 2
0
 def test_passed_geometry(self, stubs, js_rect):
     """Make sure geometry isn't called when a geometry is passed."""
     frame = stubs.FakeWebFrame(QRect(0, 0, 200, 200))
     elem = get_webelem(frame=frame, js_rect_return=js_rect)
     rect = QRect(10, 20, 30, 40)
     assert elem.rect_on_view(elem_geometry=rect) == rect
     assert not elem._elem.geometry.called
Exemplo n.º 3
0
 def test_invalid_frame_geometry(self, stubs):
     """Test with an invalid frame geometry."""
     rect = QRect(0, 0, 0, 0)
     assert not rect.isValid()
     frame = stubs.FakeWebFrame(rect)
     elem = get_webelem(QRect(0, 0, 10, 10), frame)
     assert not elem._is_visible(frame)
Exemplo n.º 4
0
 def test_zoomed(self, stubs, config_stub, js_rect, monkeypatch,
                 zoom_text_only):
     """Make sure the coordinates are adjusted when zoomed."""
     monkeypatch.setattr(objects, 'backend', usertypes.Backend.QtWebKit)
     config_stub.val.zoom.text_only = zoom_text_only
     geometry = QRect(10, 10, 4, 4)
     frame = stubs.FakeWebFrame(QRect(0, 0, 100, 100), zoom=0.5)
     elem = get_webelem(geometry, frame, js_rect_return=js_rect,
                        zoom_text_only=zoom_text_only)
     assert elem.rect_on_view() == QRect(10, 10, 4, 4)
Exemplo n.º 5
0
    def objects(self, stubs):
        """Set up the following base situation.

             0, 0                         300, 0
              ##############################
              #                            #
         0,10 # iframe  100,10             #
              #**********                  #
              #*e       * elems[0]: 0, 0 in iframe (visible)
              #*        *                  #
              #* e      * elems[1]: 20,90 in iframe (visible)
              #**********                  #
        0,110 #.        .100,110           #
              #.        .                  #
              #. e      . elems[2]: 20,150 in iframe (not visible)
              #..........                  #
              #     e     elems[3]: 30, 180 in main frame (visible)
              #                            #
              #          frame             #
              ##############################
            300, 0                         300, 300

        Returns an Objects object with frame/iframe/elems attributes.
        """
        frame = stubs.FakeWebFrame(QRect(0, 0, 300, 300))
        iframe = stubs.FakeWebFrame(QRect(0, 10, 100, 100), parent=frame)
        assert frame.geometry().contains(iframe.geometry())
        elems = [
            get_webelem(QRect(0, 0, 10, 10), iframe),
            get_webelem(QRect(20, 90, 10, 10), iframe),
            get_webelem(QRect(20, 150, 10, 10), iframe),
            get_webelem(QRect(30, 180, 10, 10), frame),
        ]

        assert elems[0]._is_visible(frame)
        assert elems[1]._is_visible(frame)
        assert not elems[2]._is_visible(frame)
        assert elems[3]._is_visible(frame)

        return self.Objects(frame=frame, iframe=iframe, elems=elems)
Exemplo n.º 6
0
    def test_iframe(self, stubs, js_rect):
        """Test an element in an iframe.

             0, 0                         200, 0
              ##############################
              #                            #
         0,10 # iframe  100,10             #
              #**********                  #
              #*        *                  #
              #*        *                  #
              #* e      * elem: 20,90 in iframe
              #**********                  #
        0,100 #                            #
              ##############################
            200, 0                         200, 200
        """
        frame = stubs.FakeWebFrame(QRect(0, 0, 200, 200))
        iframe = stubs.FakeWebFrame(QRect(0, 10, 100, 100), parent=frame)
        assert frame.geometry().contains(iframe.geometry())
        elem = get_webelem(QRect(20, 90, 10, 10), iframe,
                           js_rect_return=js_rect)
        assert elem.rect_on_view() == QRect(20, 10 + 90, 10, 10)
Exemplo n.º 7
0
 def test_scrolled(self, stubs, js_rect):
     geometry = QRect(20, 20, 4, 4)
     frame = stubs.FakeWebFrame(QRect(0, 0, 100, 100),
                                scroll=QPoint(10, 10))
     elem = get_webelem(geometry, frame, js_rect_return=js_rect)
     assert elem.rect_on_view() == QRect(20 - 10, 20 - 10, 4, 4)
Exemplo n.º 8
0
 def test_simple(self, stubs, js_rect):
     geometry = QRect(5, 5, 4, 4)
     frame = stubs.FakeWebFrame(QRect(0, 0, 100, 100))
     elem = get_webelem(geometry, frame, js_rect_return=js_rect)
     assert elem.rect_on_view() == QRect(5, 5, 4, 4)
Exemplo n.º 9
0
 def test_scrolled(self, geometry, visible, stubs):
     scrolled_frame = stubs.FakeWebFrame(QRect(0, 0, 100, 100),
                                         scroll=QPoint(10, 10))
     elem = get_webelem(geometry, scrolled_frame)
     assert elem._is_visible(scrolled_frame) == visible
Exemplo n.º 10
0
 def frame(self, stubs):
     return stubs.FakeWebFrame(QRect(0, 0, 100, 100))