1#!/usr/bin/python
2# Copyright 2013 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Host-driven Java tests which exercise sync functionality."""
7
8from pylib import constants
9from pylib.host_driven import test_case
10from pylib.host_driven import test_server
11from pylib.host_driven import tests_annotations
12
13
14class SyncTest(test_case.HostDrivenTestCase):
15  """Host-driven Java tests which exercise sync functionality."""
16
17  def __init__(self, *args, **kwargs):
18    super(SyncTest, self).__init__(*args, **kwargs)
19    self.test_server = None
20    self.additional_flags = []
21
22  def SetUp(self, device, shard_index, push_deps, cleanup_test_files):
23    self.test_server = test_server.TestServer(
24        shard_index,
25        constants.TEST_SYNC_SERVER_PORT,
26        test_server.TEST_SYNC_SERVER_PATH)
27    # These ought not to change in the middle of a test for obvious reasons.
28    self.additional_flags = [
29        '--sync-url=http://%s:%d/chromiumsync' %
30        (self.test_server.host, self.test_server.port),
31        '--sync-deferred-startup-timeout-seconds=0']
32    super(SyncTest, self).SetUp(device, shard_index, push_deps,
33                                cleanup_test_files,
34                                [self.test_server.port])
35
36  def TearDown(self):
37    super(SyncTest, self).TearDown()
38    self.test_server.TearDown()
39
40  def _RunSyncTests(self, test_names):
41    full_names = []
42    for test_name in test_names:
43      full_names.append('SyncTest.' + test_name)
44    return self._RunJavaTestFilters(full_names, self.additional_flags)
45
46  # http://crbug.com/348951
47  # @tests_annotations.Feature(['Sync'])
48  # @tests_annotations.EnormousTest
49  @tests_annotations.DisabledTest
50  def testGetAboutSyncInfoYieldsValidData(self):
51    java_tests = ['testGetAboutSyncInfoYieldsValidData']
52    return self._RunSyncTests(java_tests)
53
54  # http://crbug.com/348117
55  # @tests_annotations.Feature(['Sync'])
56  # @tests_annotations.EnormousTest
57  @tests_annotations.DisabledTest
58  def testAboutSyncPageDisplaysCurrentSyncStatus(self):
59    java_tests = ['testAboutSyncPageDisplaysCurrentSyncStatus']
60    return self._RunSyncTests(java_tests)
61
62  # http://crbug.com/348951
63  # @tests_annotations.Feature(['Sync'])
64  # @tests_annotations.EnormousTest
65  @tests_annotations.DisabledTest
66  def testDisableAndEnableSync(self):
67    java_tests = ['testDisableAndEnableSync']
68    return self._RunSyncTests(java_tests)
69