#!/usr/bin/env python
# Copyright (c) 2011 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 logging

import pyauto_functional  # Must be imported before pyauto
import pyauto

class ChromeosTime(pyauto.PyUITest):
  """Tests for the ChromeOS status area clock and timezone settings."""

  def setUp(self):
    pyauto.PyUITest.setUp(self)
    self._initial_timezone = self.GetTimeInfo()['timezone']

  def tearDown(self):
    self.SetTimezone(self._initial_timezone)
    pyauto.PyUITest.tearDown(self)

  def testTimeInfo(self):
    """Print the the display time, date, and timezone."""
    logging.debug(self.GetTimeInfo())

  def testSetTimezone(self):
    """Sanity test to make sure setting the timezone works."""
    self.SetTimezone('America/Los_Angeles')
    pacific_time = self.GetTimeInfo()['display_time']
    self.SetTimezone('America/New_York')
    eastern_time = self.GetTimeInfo()['display_time']

    self.assertNotEqual(pacific_time, eastern_time,
                        'Time zone changed but display time did not.')


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

@@ -34,17 +34,17 @@
  (c) 201
-1
+2
  The Chr
@@ -1130,16 +1130,960 @@
 not.')%0A%0A
+  def _IsTimezoneEditable(self):%0A    %22%22%22Check if the timezone is editable.%0A%0A    It will navigate to the system settings page and verify that the%0A    timezone settings drop down is not disabled.%0A%0A    Returns:%0A      True, if timezone dropdown is enabled%0A      False, otherwise%0A    %22%22%22%0A    self.NavigateToURL('chrome://settings/system')%0A    ret = self.ExecuteJavascript(%22%22%22%0A        var enabled = false;%0A        var timezone = document.getElementById('timezone-select');%0A        if (timezone)%0A          enabled = banner.enabled;%0A        domAutomationController.send(enabled.toString());%0A    %22%22%22)%0A    return ret == 'true'%0A%0A  def testTimezoneIsEditable(self):%0A    %22%22%22Test that the timezone is always editable.%22%22%22%0A    # This test only makes sense if we are not running as the owner.%0A    self.assertFalse(self.GetLoginInfo()%5B'is_owner'%5D)%0A    enabled = _IsTimezoneEditable()%0A    self.assertTrue(enabled, msg='Timezone is not editable when not owner.')%0A%0A
 %0Aif __na

Add pyauto test to verify that any user can edit the timezone.