
import unittest

import pyauto_functional  # Must be imported before pyauto
import pyauto


class PyAutoTest(pyauto.PyUITest):
  """Test functionality of the PyAuto framework."""

  _EXTRA_CHROME_FLAGS = [
    '--scooby-doo=123',
    '--donald-duck=cool',
    '--super-mario',
    '--marvin-the-martian',
  ]

  def ExtraChromeFlags(self):
    """Ensures Chrome is launched with some custom flags.

    Overrides the default list of extra flags passed to Chrome.  See
    ExtraChromeFlags() in pyauto.py.
    """
    return self._EXTRA_CHROME_FLAGS

  def testSetCustomChromeFlags(self):
    """Ensures that Chrome can be launched with custom flags."""
    self.NavigateToURL('about://version')
    for flag in self._EXTRA_CHROME_FLAGS:
      self.assertEqual(self.FindInPage(flag)['match_count'], 1,
                       msg='Missing expected Chrome flag "%s"' % flag)


if __name__ == '__main__':
  pyauto_functional.Main()


import unittest

import pyauto_functional  # Must be imported before pyauto
import pyauto


class PyAutoTest(pyauto.PyUITest):
  """Test functionality of the PyAuto framework."""

  _EXTRA_CHROME_FLAGS = [
    '--scooby-doo=123',
    '--donald-duck=cool',
    '--super-mario',
    '--marvin-the-martian',
  ]

  def ExtraChromeFlags(self):
    """Ensures Chrome is launched with some custom flags.

    Overrides the default list of extra flags passed to Chrome.  See
    ExtraChromeFlags() in pyauto.py.
    """
    return pyauto.PyUITest.ExtraChromeFlags(self) + self._EXTRA_CHROME_FLAGS

  def testSetCustomChromeFlags(self):
    """Ensures that Chrome can be launched with custom flags."""
    self.NavigateToURL('about://version')
    for flag in self._EXTRA_CHROME_FLAGS:
      self.assertEqual(self.FindInPage(flag)['match_count'], 1,
                       msg='Missing expected Chrome flag "%s"' % flag)


if __name__ == '__main__':
  pyauto_functional.Main()

Update testSetCustomChromeFlags to only append to chrome flags, not override
Update testSetCustomChromeFlags to only append to chrome flags, not override

This is in keeping with the spirit of the ExtraChromeFlags() method. Whenever
it's overridden, it should only ever append to the list of chrome flags,
never completely override it.

BUG=None
TEST=None

R=dennisjeffrey@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10041001

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@131597 0039d316-1c4b-4281-b951-d872f2087c98

  
  import unittest
  
  import pyauto_functional  # Must be imported before pyauto
  import pyauto
  
  
  class PyAutoTest(pyauto.PyUITest):
    """Test functionality of the PyAuto framework."""
  
    _EXTRA_CHROME_FLAGS = [
      '--scooby-doo=123',
      '--donald-duck=cool',
      '--super-mario',
      '--marvin-the-martian',
    ]
  
    def ExtraChromeFlags(self):
      """Ensures Chrome is launched with some custom flags.
  
      Overrides the default list of extra flags passed to Chrome.  See
      ExtraChromeFlags() in pyauto.py.
      """
-     return self._EXTRA_CHROME_FLAGS
+     return pyauto.PyUITest.ExtraChromeFlags(self) + self._EXTRA_CHROME_FLAGS
  
    def testSetCustomChromeFlags(self):
      """Ensures that Chrome can be launched with custom flags."""
      self.NavigateToURL('about://version')
      for flag in self._EXTRA_CHROME_FLAGS:
        self.assertEqual(self.FindInPage(flag)['match_count'], 1,
                         msg='Missing expected Chrome flag "%s"' % flag)
  
  
  if __name__ == '__main__':
    pyauto_functional.Main()
  
Update testSetCustomChromeFlags to only append to chrome flags, not override
## Code Before:

import unittest

import pyauto_functional  # Must be imported before pyauto
import pyauto


class PyAutoTest(pyauto.PyUITest):
  """Test functionality of the PyAuto framework."""

  _EXTRA_CHROME_FLAGS = [
    '--scooby-doo=123',
    '--donald-duck=cool',
    '--super-mario',
    '--marvin-the-martian',
  ]

  def ExtraChromeFlags(self):
    """Ensures Chrome is launched with some custom flags.

    Overrides the default list of extra flags passed to Chrome.  See
    ExtraChromeFlags() in pyauto.py.
    """
    return self._EXTRA_CHROME_FLAGS

  def testSetCustomChromeFlags(self):
    """Ensures that Chrome can be launched with custom flags."""
    self.NavigateToURL('about://version')
    for flag in self._EXTRA_CHROME_FLAGS:
      self.assertEqual(self.FindInPage(flag)['match_count'], 1,
                       msg='Missing expected Chrome flag "%s"' % flag)


if __name__ == '__main__':
  pyauto_functional.Main()

## Instruction:
Update testSetCustomChromeFlags to only append to chrome flags, not override
## Code After:

import unittest

import pyauto_functional  # Must be imported before pyauto
import pyauto


class PyAutoTest(pyauto.PyUITest):
  """Test functionality of the PyAuto framework."""

  _EXTRA_CHROME_FLAGS = [
    '--scooby-doo=123',
    '--donald-duck=cool',
    '--super-mario',
    '--marvin-the-martian',
  ]

  def ExtraChromeFlags(self):
    """Ensures Chrome is launched with some custom flags.

    Overrides the default list of extra flags passed to Chrome.  See
    ExtraChromeFlags() in pyauto.py.
    """
    return pyauto.PyUITest.ExtraChromeFlags(self) + self._EXTRA_CHROME_FLAGS

  def testSetCustomChromeFlags(self):
    """Ensures that Chrome can be launched with custom flags."""
    self.NavigateToURL('about://version')
    for flag in self._EXTRA_CHROME_FLAGS:
      self.assertEqual(self.FindInPage(flag)['match_count'], 1,
                       msg='Missing expected Chrome flag "%s"' % flag)


if __name__ == '__main__':
  pyauto_functional.Main()
