def testErrorWithUnrecognizedApkName(self):
    self.fs.CreateFile(
        '/foo/unknown.apk')
    self.finder_options.browser_executable = '/foo/unknown.apk'
    self._get_package_name_mock.return_value = 'org.foo.bar'

    with self.assertRaises(exceptions.UnknownPackageError):
      android_browser_finder._FindAllPossibleBrowsers(
          self.finder_options, self.fake_platform)
 def testNoErrorWithReferenceBuildNoPathFoundError(self):
   if not self.finder_options.chrome_root:
     self.skipTest('--chrome-root is not specified, skip the test')
   self._fetch_path_mock.side_effect = binary_manager.NoPathFoundError
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
     self.finder_options, self.fake_platform)
   self.assertNotIn('reference', [b.browser_type for b in possible_browsers])
 def testNoErrorWithReferenceBuildCloudStorageError(self):
   with mock.patch(
       'telemetry.internal.backends.chrome.android_browser_finder.binary_manager.FetchPath',  # pylint: disable=line-too-long
       side_effect=binary_manager.CloudStorageError):
     possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
         self.finder_options, self.fake_platform)
   self.assertNotIn('reference', [b.browser_type for b in possible_browsers])
  def testNoErrorWithUnrecognizedApkName(self):
    self._android_browser_finder_stub.os.path.files.append(
        '/foo/unknown.apk')
    self.finder_options.browser_executable = '/foo/unknown.apk'

    fake_platform = FakeAndroidPlatform(can_launch=True)
    possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
        self.finder_options, fake_platform)
    self.assertNotIn('exact', [b.browser_type for b in possible_browsers])
 def testCanLaunchAlwaysTrueReturnsAllExceptExactAndReference(self):
   all_types = set(
       android_browser_finder.FindAllBrowserTypes(self.finder_options))
   expected_types = all_types - set(('exact', 'reference'))
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
       self.finder_options, self.fake_platform)
   self.assertEqual(
       expected_types,
       set([b.browser_type for b in possible_browsers]))
  def testCanLaunchExactWithUnrecognizedApkNameButKnownPackageName(self):
    self.fs.CreateFile(
        '/foo/MyFooBrowser.apk')
    self._get_package_name_mock.return_value = 'org.chromium.chrome'
    self.finder_options.browser_executable = '/foo/MyFooBrowser.apk'

    possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
        self.finder_options, self.fake_platform)
    self.assertIn('exact', [b.browser_type for b in possible_browsers])
  def testNoErrorWithUnrecognizedApkName(self):
    if not self.finder_options.chrome_root:
      self.skipTest('--chrome-root is not specified, skip the test')
    self.fs.CreateFile(
        '/foo/unknown.apk')
    self.finder_options.browser_executable = '/foo/unknown.apk'

    possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
        self.finder_options, self.fake_platform)
    self.assertNotIn('exact', [b.browser_type for b in possible_browsers])
 def testCanLaunchAlwaysTrueReturnsAllExceptExact(self):
   fake_platform = FakeAndroidPlatform(can_launch=True)
   all_types = set(
       android_browser_finder.FindAllBrowserTypes(self.finder_options))
   expected_types = all_types - set(('exact',))
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
       self.finder_options, fake_platform)
   self.assertEqual(
       expected_types,
       set([b.browser_type for b in possible_browsers]))
 def testCanLaunchAlwaysTrueReturnsAllExceptExactAndReference(self):
   if not self.finder_options.chrome_root:
     self.skipTest('--chrome-root is not specified, skip the test')
   all_types = set(
       android_browser_finder.FindAllBrowserTypes(self.finder_options))
   expected_types = all_types - set(('exact', 'reference'))
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
       self.finder_options, self.fake_platform)
   self.assertEqual(
       expected_types,
       set([b.browser_type for b in possible_browsers]))
  def testCanLaunchAlwaysTrueWithExactApkReturnsAll(self):
    self._android_browser_finder_stub.os.path.files.append(
        '/foo/content-shell.apk')
    self.finder_options.browser_executable = '/foo/content-shell.apk'
    self._get_package_name_mock.return_value = 'org.chromium.content_shell_apk'

    fake_platform = FakeAndroidPlatform(can_launch=True)
    expected_types = set(
        android_browser_finder.FindAllBrowserTypes(self.finder_options))
    possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
        self.finder_options, fake_platform)
    self.assertEqual(
        expected_types,
        set([b.browser_type for b in possible_browsers]))
  def testCanLaunchAlwaysTrueWithExactApkReturnsAll(self):
    self.fs.CreateFile(
        '/foo/ContentShell.apk')
    self.fs.CreateFile(self.expected_reference_build)
    self.finder_options.browser_executable = '/foo/ContentShell.apk'
    self._get_package_name_mock.return_value = 'org.chromium.content_shell_apk'

    expected_types = set(
        android_browser_finder.FindAllBrowserTypes(self.finder_options))
    possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
        self.finder_options, self.fake_platform)
    self.assertEqual(
        expected_types,
        set([b.browser_type for b in possible_browsers]))
 def testNoPlatformReturnsEmptyList(self):
   fake_platform = None
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
       self.finder_options, fake_platform)
   self.assertEqual([], possible_browsers)
 def testNoErrorWithMissingReferenceBuild(self):
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
       self.finder_options, self.fake_platform)
   self.assertNotIn('reference', [b.browser_type for b in possible_browsers])
 def testNoErrorWithMissingReferenceBuild(self):
   if not self.finder_options.chrome_root:
     self.skipTest('--chrome-root is not specified, skip the test')
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
     self.finder_options, self.fake_platform)
   self.assertNotIn('reference', [b.browser_type for b in possible_browsers])
예제 #15
0
 def testNoErrorWithReferenceBuildNoPathFoundError(self):
     self._fetch_path_mock.side_effect = binary_manager.NoPathFoundError
     possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
         self.finder_options, self.fake_platform)
     self.assertNotIn('reference',
                      [b.browser_type for b in possible_browsers])
예제 #16
0
 def testNoErrorWithMissingReferenceBuild(self):
     possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
         self.finder_options, self.fake_platform)
     self.assertNotIn('reference',
                      [b.browser_type for b in possible_browsers])
예제 #17
0
 def testNoPlatformReturnsEmptyList(self):
   fake_platform = None
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
       self.finder_options, fake_platform)
   self.assertEqual([], possible_browsers)
예제 #18
0
 def testWebViewBrowserReturned(self):
     self.finder_options.browser_type = 'android-webview'
     possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
         self.finder_options, self.fake_platform)
     self.assertEqual(possible_browsers[0].target_os, 'android_webview')
 def testNoErrorWithMissingReferenceBuild(self):
   if not self.finder_options.chrome_root:
     self.skipTest('--chrome-root is not specified, skip the test')
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
     self.finder_options, self.fake_platform)
   self.assertNotIn('reference', [b.browser_type for b in possible_browsers])
 def testNoErrorWithReferenceBuildNoPathFoundError(self):
   self._fetch_path_mock.side_effect = binary_manager.NoPathFoundError
   possible_browsers = android_browser_finder._FindAllPossibleBrowsers(
       self.finder_options, self.fake_platform)
   self.assertNotIn('reference', [b.browser_type for b in possible_browsers])