Ejemplo n.º 1
0
 def test_media_query_combinations(self):
     self.assertTrue(
         match('screen and (min-width: 767px)', {
             'type': 'screen',
             'width': '980'
         }))
     self.assertTrue(
         match('screen and (min-width: 767px) and (max-width: 979px)', {
             'type': 'screen',
             'width': '800'
         }))
     self.assertTrue(
         match('screen and (color)', {
             'type': 'screen',
             'color': '1'
         }))
     self.assertTrue(
         match('screen and (min-width: 767px), screen and (color)', {
             'type': 'screen',
             'color': '1'
         }))
     self.assertFalse(
         match('screen and (max-width: 1200px), handheld and (monochrome)',
               {
                   'type': 'screen',
                   'monochrome': '0'
               }))
Ejemplo n.º 2
0
 def test_aspect_ratio_match(self):
     self.assertTrue(
         match('(min-aspect-ratio: 4/3)', {'aspect-ratio': '16 / 9'}))
     self.assertFalse(
         match('(max-aspect-ratio: 4/3)', {'aspect-ratio': '16/9'}))
     self.assertFalse(match('(max-aspect-ratio: 72dpi)', {"width": "300"}))
     self.assertFalse(
         match('(min-aspect-ratio: 2560/1440)', {'aspect-ratio': 4 / 3}))
Ejemplo n.º 3
0
 def test_type_match(self):
     self.assertTrue(match('screen', {'type': 'screen'}))
     self.assertFalse(
         match('screen and (color:1)', {
             'type': 'tv',
             'color': '1'
         }))
     self.assertFalse(match('(min-width: 500px)', {'type': 'screen'}))
Ejemplo n.º 4
0
 def test_not_match(self):
     self.assertTrue(
         match('not screen and (color), screen and (min-height: 48em)', {
             'type': 'screen',
             'height': '1000'
         }))
     self.assertFalse(
         match('not all and (min-width: 48em)', {
             'type': 'all',
             'width': '1000'
         }))
Ejemplo n.º 5
0
 def test_not_query_match(self):
     self.assertFalse(
         match('not screen and (color)', {
             "type": 'screen',
             "color": "1"
         }))
     self.assertTrue(
         match('not screen and (color), screen and (min-height: 48em)', {
             "type": 'screen',
             "height": "1000"
         }))
     self.assertTrue(
         match('not screen and (color), screen and (min-height: 48em)', {
             "type": 'screen',
             "height": "1000"
         }))
Ejemplo n.º 6
0
 def test_resolution_match(self):
     self.assertTrue(match("(resolution: 50dpi)", {"resolution": "50"}))
     self.assertTrue(match('(min-resolution: 50dpi)', {"resolution": "72"}))
     self.assertFalse(match('(min-resolution: 72dpi)', {"width": "300"}))
     self.assertFalse(match('(min-resolution: 72dpi)', {"width": "75dpcm"}))
     self.assertTrue(match("(resolution: 192dpi)", {"resolution": "2dppx"}))
Ejemplo n.º 7
0
 def test_different_unit_match(self):
     self.assertTrue(match("(min-width: 500px)", {"width": "48em"}))
     self.assertTrue(match("(min-width: 500px)", {"width": "48rem"}))
     self.assertTrue(match("(max-height: 1000px)", {"height": "20cm"}))
     self.assertFalse(match("(max-height: 1000px)", {"height": "850pt"}))
     self.assertTrue(match("(max-height: 1000px)", {"height": "60pc"}))
Ejemplo n.º 8
0
 def test_width_range_match(self):
     self.assertTrue(match("(min-width: 48em)", {"width": "80em"}))
     self.assertFalse(match("(min-width: 48em)", {"width": "20em"}))
     self.assertFalse(match("(min-width: 48em)", {"resolution": "72"}))
Ejemplo n.º 9
0
 def test_width_match(self):
     self.assertTrue(match("(width: 800px)", {"width": "800"}))
     self.assertFalse(match("(width: 800px)", {"width": "810"}))
Ejemplo n.º 10
0
    def test_scan_match(self):
        self.assertTrue(match("(scan: progressive)", {"scan": "progressive"}))

        self.assertFalse(match("(scan: progressive)", {"scan": "interlace"}))
Ejemplo n.º 11
0
    def test_orientation_match(self):
        self.assertTrue(
            match("(orientation: portrait)", {"orientation": "portrait"}))

        self.assertFalse(
            match("(orientation: landscape)", {"orientation": "portrait"}))