Example #1
0
 def test_render(self):
     text = Text("Hello world!")
     MagicView.test_render(
         root_view=text,
         container_size=Size(200, 200),
         expected_content_size=Size(86, 17)  # Some fixed value
     )
Example #2
0
 def test_padding_specific(self):
     padding = Padding(padding=EdgeInsets(10, 20, 30, 40),
                       child=MagicView(
                           content_size=Size(100, 100),
                           expected_container_size=Size(160, 140),
                           expected_origin=Point(10, 20),
                       ))
     MagicView.test_render(root_view=padding,
                           container_size=Size(200, 200),
                           expected_content_size=Size(140, 160))
Example #3
0
 def test_center(self):
     center = Center(child=MagicView(
         content_size=Size(100, 100),
         expected_container_size=Size(200, 200),
         expected_origin=Point(50, 50),
     ))
     MagicView.test_render(
         root_view=center,
         container_size=Size(200, 200),
         expected_content_size=Size(200, 200),
     )
Example #4
0
 def test_center(self):
     MagicView.test_render(
         root_view=Offset(offset=Point(10, 10),
                          child=MagicView(
                              content_size=Size(100, 100),
                              expected_container_size=Size(200, 200),
                              expected_origin=Point(10, 10),
                          )),
         container_size=Size(200, 200),
         expected_content_size=Size(100, 100),
     )
Example #5
0
 def test_padding_all(self):
     padding = Padding(padding=EdgeInsets.all(10),
                       child=MagicView(
                           content_size=Size(100, 100),
                           expected_container_size=Size(180, 180),
                           expected_origin=Point(10, 10),
                       ))
     MagicView.test_render(
         root_view=padding,
         container_size=Size(200, 200),
         expected_content_size=Size(120, 120),
     )
Example #6
0
 def test_horizontal_align_end_super(self):
     MagicView.test_render(
         container_size=Size(200, 200),
         root_view=VerticalStack(children=[
             MagicView(
                 content_size=Size(250, 50),
                 expected_container_size=Size(200, 200),
                 expected_origin=Point(-50, 0),
             ).named("first view"),
         ],
                                 alignment=StackAlignment.End),
     )
Example #7
0
 def test_padding_symmetric(self):
     padding = Padding(padding=EdgeInsets.symmetric(horizontal=10,
                                                    vertical=20),
                       child=MagicView(
                           content_size=Size(100, 100),
                           expected_container_size=Size(180, 160),
                           expected_origin=Point(10, 20),
                       ))
     MagicView.test_render(
         root_view=padding,
         container_size=Size(200, 200),
         expected_content_size=Size(120, 140),
     )
Example #8
0
 def test_horizontal_spacing_ten_dist_equal_align_start(self):
     MagicView.test_render(
         container_size=Size(200, 200),
         root_view=HorizontalStack(children=[
             MagicView(
                 content_size=Size(50, 50),
                 expected_container_size=Size(95, 200),
                 expected_origin=Point(0, 0),
             ).named("first view"),
             MagicView(
                 content_size=Size(50, 50),
                 expected_container_size=Size(95, 200),
                 expected_origin=Point(105, 0),
             ).named("second view"),
         ],
                                   spacing=10,
                                   distribution=StackDistribution.Equal,
                                   alignment=StackAlignment.Start),
         expected_content_size=Size(200, 50),
     )
Example #9
0
 def test_vertical_spacing_ten_dist_start_align_start(self):
     MagicView.test_render(
         container_size=Size(100, 200),
         root_view=VerticalStack(children=[
             MagicView(
                 content_size=Size(50, 50),
                 expected_container_size=Size(100, 200),
                 expected_origin=Point(0, 0),
             ).named("first view"),
             MagicView(
                 content_size=Size(50, 50),
                 expected_container_size=Size(100, 140),
                 expected_origin=Point(0, 60),
             ).named("second view"),
         ],
                                 spacing=10,
                                 distribution=StackDistribution.Start,
                                 alignment=StackAlignment.Start),
         expected_content_size=Size(50, 110),
     )