Example #1
0
    def four(self) -> Expectation:
        layout = ViewTree.layout(
            SimpleLayout.cons('root'),
            List(
                ViewTree.pane(
                    SimplePane.cons('one',
                                    geometry=ViewGeometry.cons(min_size=30))),
                ViewTree.layout(
                    SimpleLayout.cons('main', vertical=false),
                    List(
                        ViewTree.pane(SimplePane.cons('two')),
                        ViewTree.layout(
                            SimpleLayout.cons('sub1'),
                            List(
                                ViewTree.pane(SimplePane.cons('three')),
                                ViewTree.layout(
                                    SimpleLayout.cons('sub2', vertical=false),
                                    List(
                                        ViewTree.pane(SimplePane.cons('four')),
                                        ViewTree.pane(SimplePane.cons('five')),
                                    )))))),
            ))
        data = SpecData.cons(layout)

        @do(TS[SpecData, None])
        def go() -> Do:
            yield ui_open_simple_pane('one')
            yield ui_open_simple_pane('two')
            yield ui_open_simple_pane('three')
            yield ui_open_simple_pane('four')
            yield open_simple_pane('five')
            yield all_panes().state

        s, panes = self.run(go(), data)
        return k(panes).must(have_length(5))
Example #2
0
    def three(self) -> Expectation:
        layout = ViewTree.layout(
            SimpleLayout.cons('root', vertical=true),
            List(
                ViewTree.pane(
                    SimplePane.cons(StrIdent('one'),
                                    geometry=ViewGeometry.cons(max_size=10))),
                ViewTree.pane(
                    SimplePane.cons(StrIdent('two'),
                                    geometry=ViewGeometry.cons(max_size=10))),
                ViewTree.pane(
                    SimplePane.cons(StrIdent('three'),
                                    geometry=ViewGeometry.cons(max_size=10))),
            ))
        data = SpecData.cons(layout)

        @do(TS[SpecData, List[PaneData]])
        def go() -> Do:
            yield ui_open_simple_pane(StrIdent('one'))
            yield ui_open_simple_pane(StrIdent('two'))
            yield open_simple_pane(StrIdent('three'))
            panes = yield all_panes().state
            positions = panes / _.position
            yield TS.from_maybe(positions.lift_all(0, 1, 2),
                                'invalid number of panes')

        s, (p1, p2, p3) = self.run(go(), data)
        return k(p3 - p2) == (p2 - p1)
Example #3
0
 def two_vertical(self) -> Expectation:
     data = SpecData.cons(two_vertical)
     @do(TS[SpecData, None])
     def go() -> Do:
         yield ui_open_simple_pane(StrIdent('one'))
         yield ui_open_simple_pane(StrIdent('two'))
         yield TS.modify(minimize_layout('right'))
         yield simple_render()
         yield all_panes().state
         self._wait(1)
     s, panes = self.run(go(), data)
     return k(panes.drop(1).map(lambda a: a.width)) == List(2)
Example #4
0
 def minimize(self) -> Expectation:
     data = SpecData.cons(three)
     @do(TS[SpecData, None])
     def go() -> Do:
         yield ui_open_simple_pane(StrIdent('one'))
         yield ui_open_simple_pane(StrIdent('two'))
         yield open_simple_pane(StrIdent('three'))
         yield TS.modify(minimize_layout('sub'))
         yield simple_render()
         yield all_panes().state
     s, panes = self.run(go(), data)
     return k(panes[1:].map(lambda a: a.width)) == List(2, 2)
Example #5
0
 def focus(self) -> Expectation:
     layout = ViewTree.layout(
         SimpleLayout.cons('main', vertical=true),
         List(
             ViewTree.pane(SimplePane.cons('one')),
             ViewTree.pane(SimplePane.cons('two')),
         ),
     )
     data = SpecData.cons(layout)
     @do(TS[SpecData, None])
     def go() -> Do:
         yield ui_open_simple_pane(StrIdent('one'))
         yield open_simple_pane(StrIdent('two'))
         yield all_panes().state
         yield TS.lift(pdata())
     (s, r) = self.run(go(), data)
     return k(r) == List(FData(0, True), FData(1, False))
Example #6
0
    def one_sub(self) -> Expectation:
        layout = ViewTree.layout(
            SimpleLayout.cons('main', vertical=true),
            List(
                ViewTree.pane(SimplePane.cons('one')),
                ViewTree.layout(
                    SimpleLayout.cons('sub', vertical=false),
                    List(
                        ViewTree.pane(SimplePane.cons('two')),
                        ViewTree.pane(SimplePane.cons('three')),
                    )),
            ))
        data = SpecData.cons(layout)

        @do(TS[SpecData, None])
        def go() -> Do:
            yield ui_open_simple_pane(StrIdent('one'))
            yield ui_open_simple_pane(StrIdent('two'))
            yield open_simple_pane(StrIdent('three'))
            yield all_panes().state

        s, panes = self.run(go(), data)
        return k(panes).must(have_length(3))
Example #7
0
 def run() -> Do:
     data = SpecData.cons(config.layout)
     yield io(*a, **kw).run_a(data)