summaryrefslogtreecommitdiffstats
path: root/chrome/test/functional/sync.py
blob: 295eb916cc802e3be99e70f3ab3ba42a4c9f4c7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/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 pyauto_functional  # Must be imported before pyauto
import pyauto


class SyncTest(pyauto.PyUITest):
  """Tests for sync."""

  def testSignInToSync(self):
    """Sign in to sync."""
    creds = self.GetPrivateInfo()['test_google_account']
    username = creds['username']
    password = creds['password']
    new_timeout = pyauto.PyUITest.ActionTimeoutChanger(self,
                                                       60 * 1000)  # 1 min.
    self.assertTrue(self.GetSyncInfo()['summary'] == 'OFFLINE_UNUSABLE')
    self.assertTrue(self.GetSyncInfo()['last synced'] == 'Never')
    self.assertTrue(self.SignInToSync(username, password))
    self.assertTrue(self.GetSyncInfo()['summary'] == 'READY')
    self.assertTrue(self.GetSyncInfo()['last synced'] == 'Just now')

  def testDisableAndEnableDatatypes(self):
    """Sign in, disable and then enable sync for multiple sync datatypes."""
    creds = self.GetPrivateInfo()['test_google_account']
    username = creds['username']
    password = creds['password']
    new_timeout = pyauto.PyUITest.ActionTimeoutChanger(self,
                                                       2 * 60 * 1000)  # 2 min.
    self.assertTrue(self.SignInToSync(username, password))
    self.assertTrue(self.GetSyncInfo()['summary'] == 'READY')
    self.assertTrue(self.GetSyncInfo()['last synced'] == 'Just now')
    self.assertTrue(self.DisableSyncForDatatypes(['Apps', 'Autofill',
        'Bookmarks', 'Extensions', 'Preferences', 'Themes']))
    self.assertFalse('Apps' in self.GetSyncInfo()['synced datatypes'])
    self.assertFalse('Autofill' in self.GetSyncInfo()['synced datatypes'])
    self.assertFalse('Bookmarks' in self.GetSyncInfo()['synced datatypes'])
    self.assertFalse('Extensions' in self.GetSyncInfo()['synced datatypes'])
    self.assertFalse('Preferences' in self.GetSyncInfo()['synced datatypes'])
    self.assertFalse('Themes' in self.GetSyncInfo()['synced datatypes'])
    self.assertTrue(self.EnableSyncForDatatypes(['Apps', 'Autofill',
        'Bookmarks', 'Extensions', 'Preferences','Themes']))
    self.assertTrue(self.DisableSyncForDatatypes(['Passwords']))
    self.assertTrue('Apps' in self.GetSyncInfo()['synced datatypes'])
    self.assertTrue('Autofill' in self.GetSyncInfo()['synced datatypes'])
    self.assertTrue('Bookmarks' in self.GetSyncInfo()['synced datatypes'])
    self.assertTrue('Extensions' in self.GetSyncInfo()['synced datatypes'])
    self.assertTrue('Preferences' in self.GetSyncInfo()['synced datatypes'])
    self.assertTrue('Themes' in self.GetSyncInfo()['synced datatypes'])
    self.assertFalse('Passwords' in self.GetSyncInfo()['synced datatypes'])

  def testRestartBrowser(self):
    """Sign in to sync and restart the browser."""
    creds = self.GetPrivateInfo()['test_google_account']
    username = creds['username']
    password = creds['password']
    new_timeout = pyauto.PyUITest.ActionTimeoutChanger(self,
                                                       2 * 60 * 1000)  # 2 min.
    self.assertTrue(self.SignInToSync(username, password))
    self.assertTrue(self.GetSyncInfo()['summary'] == 'READY')
    self.assertTrue(self.GetSyncInfo()['last synced'] == 'Just now')
    self.RestartBrowser(clear_profile=False)
    self.assertTrue(self.AwaitSyncRestart())
    self.assertTrue(self.GetSyncInfo()['summary'] == 'READY')
    self.assertTrue(self.GetSyncInfo()['last synced'] == 'Just now')
    self.assertTrue(self.GetSyncInfo()['updates received'] == 0)

  def testPersonalStuffSyncSection(self):
    """Verify the Sync section in Preferences before and after sync."""
    creds = self.GetPrivateInfo()['test_google_account']
    username = creds['username']
    password = creds['password']
    default_text = 'Keep everything synced or choose what data to sync'
    set_up_button = 'Set Up Sync'
    customize_button = 'Customize'
    stop_button = 'Stop Sync'
    signed_in_text = 'Google Dashboard'
    chrome_personal_stuff_url = 'chrome://settings/personal'
    new_timeout = pyauto.PyUITest.ActionTimeoutChanger(self,
                                                       2 * 60 * 1000)  # 2 min.
    self.AppendTab(pyauto.GURL(chrome_personal_stuff_url))
    self.assertTrue(self.WaitUntil(
        lambda: self.FindInPage(default_text, tab_index=1)['match_count'],
                expect_retval=1),
        'No default sync text.')
    self.assertTrue(self.WaitUntil(
        lambda: self.FindInPage(set_up_button, tab_index=1)['match_count'],
                expect_retval=1),
        'No set up sync button.')

    self.assertTrue(self.SignInToSync(username, password))
    self.GetBrowserWindow(0).GetTab(1).Reload()
    self.assertTrue(self.WaitUntil(
        lambda: self.FindInPage(username, tab_index=1)['match_count'],
                expect_retval=1),
        'No sync user account information.')
    self.assertTrue(self.WaitUntil(
        lambda: self.FindInPage(signed_in_text, tab_index=1)['match_count'],
                expect_retval=1),
        'No Google Dashboard information after signing in.')
    self.assertTrue(self.WaitUntil(
        lambda: self.FindInPage(stop_button, tab_index=1)['match_count'],
                expect_retval=1),
        'No stop sync button.')
    self.assertTrue(self.WaitUntil(
        lambda: self.FindInPage(customize_button, tab_index=1)['match_count'],
                expect_retval=1),
        'No customize sync button.')


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