Example #1
0
 def _SwapSafariProfile(self):
     """Swaps the test Safari profile with the original one."""
     self._safari_replacer = pyauto_utils.ExistingPathReplacer(
         self._safari_profiles_path)
     self._UnzipProfileToDir(
         os.path.join(self.DataDir(), 'import', 'safari', 'mac.zip'),
         self._safari_profiles_path)
Example #2
0
    def testRendererCrash(self):
        """Verify renderer's crash reporting.

    Attempts to crash, and then checks that crash dumps get generated.  Does
    not actually test crash reports on the server.
    """
        # Bail out if not a branded build
        properties = self.GetBrowserInfo()['properties']
        if properties['branding'] != 'Google Chrome':
            return

        # Make sure Chrome minidumps are enabled on Chrome OS
        if self.IsChromeOS():
            minidumps_file = '/mnt/stateful_partition/etc/enable_chromium_minidumps'
            assert os.path.exists(
                minidumps_file), 'Chrome minidumps are not enabled.'

        breakpad_folder = properties['DIR_CRASH_DUMPS']
        self.assertTrue(breakpad_folder, 'Cannot figure crash dir')

        unused = pyauto_utils.ExistingPathReplacer(path=breakpad_folder)
        # If the temp dir was created as root on chromeos, make sure chronos can
        # write to it
        if self.IsChromeOS() and os.geteuid() == 0:
            os.chown(breakpad_folder, 1000, 1000)
        self.NavigateToURL('about:crash')  # Trigger renderer crash
        dmp_files = glob.glob(os.path.join(breakpad_folder, '*.dmp'))
        self.assertEqual(1, len(dmp_files))
 def testNonExistingFile(self):
   """Test when the requested file does not exist."""
   myfile = os.path.join(self._workdir, 'myfile.txt')
   self.assertFalse(os.path.isfile(myfile))
   r = pyauto_utils.ExistingPathReplacer(myfile, path_type='file')
   self.assertTrue(os.path.isfile(myfile))
   del r
   self.assertEqual(0, len(os.listdir(self._workdir)))
 def testNonExistingDir(self):
   """Test when the requested dir does not exist."""
   mydir = os.path.join(self._workdir, 'mydir')
   self.assertFalse(os.path.isdir(mydir))
   r = pyauto_utils.ExistingPathReplacer(mydir, path_type='dir')
   self.assertTrue(os.path.isdir(mydir))
   self.assertEqual(0, len(os.listdir(mydir)))
   del r
   self.assertFalse(os.path.isdir(mydir))
 def testExistingFile(self):
   """Test when the requested file exists."""
   myfile = os.path.join(self._workdir, 'myfile.txt')
   self._CreateFile(myfile)
   self.assertTrue(self._IsOrigFile(myfile))
   r = pyauto_utils.ExistingPathReplacer(myfile, path_type='file')
   self.assertFalse(self._IsOrigFile(myfile))
   self.assertEqual(2, len(os.listdir(self._workdir)))
   del r
   self.assertEqual(1, len(os.listdir(self._workdir)))
   self.assertTrue(self._IsOrigFile(myfile))
 def testExistingDir(self):
   """Test when the requested dir exists."""
   # Create a dir with one file
   mydir = os.path.join(self._workdir, 'mydir')
   os.makedirs(mydir)
   self.assertEqual(1, len(os.listdir(self._workdir)))
   myfile = os.path.join(mydir, 'myfile.txt')
   open(myfile, 'w').close()
   self.assertTrue(os.path.isfile(myfile))
   r = pyauto_utils.ExistingPathReplacer(mydir)
   self.assertEqual(2, len(os.listdir(self._workdir)))
   self.assertFalse(os.path.isfile(myfile))
   del r
   self.assertEqual(1, len(os.listdir(self._workdir)))
   self.assertTrue(os.path.isfile(myfile))
Example #7
0
    def testRendererCrash(self):
        """Verify renderer's crash reporting.

    Attempts to crash, and then checks that crash dumps get generated.  Does
    not actually test crash reports on the server.
    """
        # bail out if not a branded build
        properties = self.GetBrowserInfo()['properties']
        if properties['branding'] != 'Google Chrome':
            return
        breakpad_folder = properties['DIR_CRASH_DUMPS']
        self.assertTrue(breakpad_folder, 'Cannot figure crash dir')

        unused = pyauto_utils.ExistingPathReplacer(path=breakpad_folder)
        self.NavigateToURL('about:crash')  # Trigger renderer crash
        dmp_files = glob.glob(os.path.join(breakpad_folder, '*.dmp'))
        self.assertEqual(1, len(dmp_files))
Example #8
0
 def _SwapFirefoxProfile(self):
     """Swaps the test Firefox profile with the original one."""
     self._firefox_replacer = pyauto_utils.ExistingPathReplacer(
         self._firefox_profiles_path)
     self._UnzipProfileToDir(self._firefox_test_profile,
                             self._firefox_profiles_path)