1# Copyright 2023 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import unittest 6from argparse import ArgumentTypeError 7 8from crossbench.browsers.splash_screen import SplashScreen, URLSplashScreen 9from tests import test_helper 10 11 12class SplashScreenTestCase(unittest.TestCase): 13 14 def test_prase_invalid(self): 15 for invalid in ("a", "1", "{}"): 16 with self.assertRaises(ArgumentTypeError): 17 SplashScreen.parse(invalid) 18 19 def test_parse_default(self): 20 self.assertEqual(SplashScreen.parse(""), SplashScreen.DEFAULT) 21 self.assertEqual(SplashScreen.parse("default"), SplashScreen.DEFAULT) 22 23 def test_parse_named(self): 24 self.assertEqual(SplashScreen.parse("none"), SplashScreen.NONE) 25 self.assertEqual(SplashScreen.parse("minimal"), SplashScreen.MINIMAL) 26 self.assertEqual(SplashScreen.parse("detailed"), SplashScreen.DETAILED) 27 28 def test_parse_url(self): 29 splash = SplashScreen.parse("http://splash.com") 30 self.assertIsInstance(splash, URLSplashScreen) 31 self.assertEqual(splash.url, "http://splash.com") 32 33 def test_parse_file(self): 34 splash = SplashScreen.parse(__file__) 35 self.assertIsInstance(splash, URLSplashScreen) 36 self.assertIn("file://", splash.url) 37 38 39if __name__ == "__main__": 40 test_helper.run_pytest(__file__) 41