Ejemplo n.º 1
0
 def test_specify_ash_chrome_version(self, mock_popen, mock_download, *_):
   args = [
       'script_name', 'test', 'browser_tests', '--ash-chrome-version', '781122'
   ]
   with mock.patch.object(sys, 'argv', args):
     test_runner.Main()
     mock_download.assert_called_with('781122')
Ejemplo n.º 2
0
    def test_require_ash_chrome(self, command, mock_popen, mock_download, *_):
        args = ['script_name', 'test', command]
        with mock.patch.object(sys, 'argv', args):
            test_runner.Main()
            mock_download.assert_called_with('793554')
            self.assertEqual(2, mock_popen.call_count)

            ash_chrome_args = mock_popen.call_args_list[0][0][0]
            self.assertTrue(ash_chrome_args[0].endswith(
                'build/lacros/prebuilt_ash_chrome/793554/chrome'))
            self.assertListEqual([
                '--user-data-dir=/tmp/ash-data', '--enable-wayland-server',
                '--no-startup-window'
            ], ash_chrome_args[1:])
            ash_chrome_env = mock_popen.call_args_list[0][1].get('env', {})
            self.assertDictEqual({'XDG_RUNTIME_DIR': '/tmp/xdg'},
                                 ash_chrome_env)

            test_args = mock_popen.call_args_list[1][0][0]
            self.assertListEqual([command], test_args)
            test_env = mock_popen.call_args_list[1][1].get('env', {})
            self.assertDictEqual(
                {
                    'XDG_RUNTIME_DIR': '/tmp/xdg',
                    'EGL_PLATFORM': 'surfaceless'
                }, test_env)
Ejemplo n.º 3
0
 def test_do_not_require_ash_chrome(self, command, mock_subprocess,
                                    mock_download):
     args = ['script_name', command]
     with mock.patch.object(sys, 'argv', args):
         test_runner.Main()
         mock_subprocess.assert_called_with([command])
         self.assertFalse(mock_download.called)
Ejemplo n.º 4
0
 def test_do_not_require_ash_chrome(self, command, mock_popen, mock_download,
                                    _):
   args = ['script_name', 'test', command]
   with mock.patch.object(sys, 'argv', args):
     test_runner.Main()
     self.assertEqual(1, mock_popen.call_count)
     mock_popen.assert_called_with([command])
     self.assertFalse(mock_download.called)
Ejemplo n.º 5
0
    def test_version_skew_ash_newer(self, *_):
        args = [
            'script_name', 'test', './browser_tests',
            '--gtest_filter=Suite.Test', '--ash-chrome-path-override=\
lacros_version_skew_tests_v92.0.100.0/test_ash_chrome'
        ]
        with mock.patch.object(sys, 'argv', args):
            self.assertEqual(test_runner.Main(), 0)
Ejemplo n.º 6
0
 def test_command_arguments(self, mock_popen, mock_download, _):
   args = [
       'script_name', 'test', './url_unittests', '--gtest_filter=Suite.Test'
   ]
   with mock.patch.object(sys, 'argv', args):
     test_runner.Main()
     mock_popen.assert_called_with(
         ['./url_unittests', '--gtest_filter=Suite.Test'])
     self.assertFalse(mock_download.called)
Ejemplo n.º 7
0
 def test_ash_wrapper(self, mock_popen, *_):
   args = [
       'script_name', 'test', './browser_tests', '--gtest_filter=Suite.Test'
   ]
   with mock.patch.object(sys, 'argv', args):
     test_runner.Main()
     ash_args = mock_popen.call_args_list[0][0][0]
     self.assertTrue(ash_args[2].endswith('test_ash_chrome'))
     self.assertEqual(['gdb', '--args'], ash_args[:2])
Ejemplo n.º 8
0
 def test_overrides_do_not_require_ash_chrome(self, mock_popen, mock_download,
                                              *_):
   args = [
       'script_name', 'test', './url_unittests', '--ash-chrome-version',
       '793554'
   ]
   with mock.patch.object(sys, 'argv', args):
     test_runner.Main()
     mock_download.assert_called_with('793554')
     self.assertEqual(2, mock_popen.call_count)
Ejemplo n.º 9
0
 def test_specify_ash_chrome_path(self, mock_popen, mock_download,
                                  mock_get_latest_version, *_):
   args = [
       'script_name',
       'test',
       'browser_tests',
       '--ash-chrome-path',
       '/ash/test_ash_chrome',
   ]
   with mock.patch.object(sys, 'argv', args):
     test_runner.Main()
     self.assertFalse(mock_get_latest_version.called)
     self.assertFalse(mock_download.called)
Ejemplo n.º 10
0
    def test_require_ash_chrome(self, command, mock_popen, mock_download, *_):
        args = ['script_name', 'test', command]
        with mock.patch.object(sys, 'argv', args):
            test_runner.Main()
            mock_download.assert_called_with('793554')
            self.assertEqual(2, mock_popen.call_count)

            ash_chrome_args = mock_popen.call_args_list[0][0][0]
            self.assertTrue(ash_chrome_args[0].endswith(
                'build/lacros/prebuilt_ash_chrome/793554/chrome'))
            expected_ash_chrome_args = [
                '--user-data-dir=/tmp/ash-data',
                '--enable-wayland-server',
                '--no-startup-window',
                '--use-fake-ml-service-for-test',
            ]
            if command == 'lacros_chrome_browsertests':
                expected_ash_chrome_args.append(
                    '--lacros-mojo-socket-for-testing=/tmp/ash-data/lacros.sock'
                )
            self.assertListEqual(expected_ash_chrome_args, ash_chrome_args[1:])
            ash_chrome_env = mock_popen.call_args_list[0][1].get('env', {})
            self.assertDictEqual({'XDG_RUNTIME_DIR': '/tmp/xdg'},
                                 ash_chrome_env)

            test_args = mock_popen.call_args_list[1][0][0]
            if command == 'lacros_chrome_browsertests':
                self.assertListEqual([
                    command,
                    '--lacros-mojo-socket-for-testing=/tmp/ash-data/lacros.sock',
                    '--test-launcher-jobs=1'
                ], test_args)
            else:
                self.assertListEqual([command], test_args)

            test_env = mock_popen.call_args_list[1][1].get('env', {})
            self.assertDictEqual(
                {
                    'XDG_RUNTIME_DIR': '/tmp/xdg',
                    'EGL_PLATFORM': 'surfaceless'
                }, test_env)
Ejemplo n.º 11
0
 def test_download_for_bots(self, mock_download):
   args = ['script_name', 'download_for_bots']
   with mock.patch.object(sys, 'argv', args):
     test_runner.Main()
     mock_download.assert_called_with('for_bots', True)
Ejemplo n.º 12
0
 def test_command_arguments(self, mock_subprocess):
     args = ['script_name', './url_unittests', '--gtest_filter=Suite.Test']
     with mock.patch.object(sys, 'argv', args):
         test_runner.Main()
         mock_subprocess.assert_called_with(
             ['./url_unittests', '--gtest_filter=Suite.Test'])