old_contents: #!/usr/bin/env python
  # Copyright (c) 2012 The Chromium Authors. All rights reserved.
  # Use of this source code is governed by a BSD-style license that can be
  # found in the LICENSE file.
  
  import os
  
  import pyauto_functional  # must be imported before pyauto
  
  import chromeos.file_browser
  import pyauto
  import test_utils
  
  
  class DocViewingTest(pyauto.PyUITest):
    """Basic tests for ChromeOS document viewing.
  
    Requires ChromeOS to be logged in.
    """
  
    def setUp(self):
      pyauto.PyUITest.setUp(self)
      extension_path = '/opt/google/chrome/extensions'\
          '/gbkeegbaiigmenfmjfclcdgdpimamgkj.crx'
      ext_id = self.InstallExtension(extension_path, from_webstore=True)
      self.assertTrue(ext_id, msg='Failed to install extension %s' %
                      extension_path)
  
    def _GetFullPageFileBrowser(self):
      """Display the full page file browser.
  
      Returns:
        ChromeosFileBrowser object.
      """
      self.NavigateToURL('chrome://files/#/Downloads')
      executor = pyauto.PyUITest.JavascriptExecutorInTab(self)
      file_browser = chromeos.file_browser.FileBrowser(self, executor)
      if file_browser.WaitUntilInitialized():
        return file_browser
      else:
        return None
  
    def testOpenOfficeFiles(self):
      """Test we can open office files from the file manager."""
      path = os.path.abspath(os.path.join(self.DataDir(),
                                          'pyauto_private', 'office'))
      # Copy sample files to Downloads directory.
      for (path, dirs, private_office_files) in os.walk(path):
        # Open sample files: .ppt, .pptx, .doc, .docx, xls, xlsx.
        for fname in private_office_files:
          test_utils.CopyFileFromDataDirToDownloadDir(self, os.path.join(path,
                                                                         fname))
          file_browser = self._GetFullPageFileBrowser()
          self.assertTrue(file_browser, msg='File browser failed to initialize.')
          self.assertTrue(file_browser.Select(fname),
                          msg='"%s" does not exist.' % fname)
          file_browser.OpenFromFileManager()
          self.assertTrue(self.WaitUntil(self.GetActiveTabTitle,
                          expect_retval=fname),
                          msg='"%s" does not open.' % fname)
          # Close the document viewing tab after use.
          self.GetBrowserWindow(0).GetTab(1).Close(True)
  
  
  if __name__ == '__main__':
    pyauto_functional.Main()
  
new_contents: #!/usr/bin/env python
  # Copyright (c) 2012 The Chromium Authors. All rights reserved.
  # Use of this source code is governed by a BSD-style license that can be
  # found in the LICENSE file.
  
  import os
  
  import pyauto_functional  # must be imported before pyauto
  
  import chromeos.file_browser
  import pyauto
  import test_utils
  
  
  class DocViewingTest(pyauto.PyUITest):
    """Basic tests for ChromeOS document viewing.
  
    Requires ChromeOS to be logged in.
    """
  
    def setUp(self):
      pyauto.PyUITest.setUp(self)
      extension_path = '/opt/google/chrome/extensions'\
          '/gbkeegbaiigmenfmjfclcdgdpimamgkj.crx'
      ext_id = self.InstallExtension(extension_path, from_webstore=True)
      self.assertTrue(ext_id, msg='Failed to install extension %s' %
                      extension_path)
  
    def _GetFullPageFileBrowser(self):
      """Display the full page file browser.
  
      Returns:
        ChromeosFileBrowser object.
      """
      self.NavigateToURL('chrome://files/#/Downloads')
      executor = pyauto.PyUITest.JavascriptExecutorInTab(self)
      file_browser = chromeos.file_browser.FileBrowser(self, executor)
      if file_browser.WaitUntilInitialized():
        return file_browser
      else:
        return None
  
    def testOpenOfficeFiles(self):
      """Test we can open office files from the file manager."""
      path = os.path.abspath(os.path.join(self.DataDir(),
                                          'pyauto_private', 'office'))
      # Copy sample files to Downloads directory.
      for (path, dirs, private_office_files) in os.walk(path):
        # Open sample files: .ppt, .pptx, .doc, .docx, xls, xlsx.
        for fname in private_office_files:
          test_utils.CopyFileFromDataDirToDownloadDir(self, os.path.join(path,
                                                                         fname))
          file_browser = self._GetFullPageFileBrowser()
          self.assertTrue(file_browser, msg='File browser failed to initialize.')
          self.assertTrue(file_browser.Select(fname),
                          msg='"%s" does not exist.' % fname)
          file_browser.ExecuteDefaultTask()
          self.assertTrue(self.WaitUntil(self.GetActiveTabTitle,
                          expect_retval=fname),
                          msg='"%s" does not open.' % fname)
          # Close the document viewing tab after use.
          self.GetBrowserWindow(0).GetTab(1).Close(True)
  
  
  if __name__ == '__main__':
    pyauto_functional.Main()
  
subject: Fix doc_viewing failing test. http://cautotest/results/dashboard/lumpy/lumpy-r22/pyauto.html