OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ | 5 #ifndef CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ |
6 #define CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ | 6 #define CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "chrome/test/in_process_browser_test.h" | 9 #include "chrome/test/in_process_browser_test.h" |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/scoped_vector.h" | 14 #include "base/scoped_vector.h" |
15 #include "chrome/test/live_sync/profile_sync_service_test_harness.h" | 15 #include "chrome/test/live_sync/profile_sync_service_test_harness.h" |
16 #include "net/base/mock_host_resolver.h" | 16 #include "net/base/mock_host_resolver.h" |
17 #include "net/test/test_server.h" | 17 #include "net/test/test_server.h" |
18 | 18 |
19 #include <string> | 19 #include <string> |
20 #include <vector> | 20 #include <vector> |
21 | 21 |
22 class CommandLine; | 22 class CommandLine; |
23 class Profile; | 23 class Profile; |
| 24 class URLRequestContextGetter; |
24 | 25 |
25 namespace net { | 26 namespace net { |
| 27 class ProxyConfig; |
26 class ScopedDefaultHostResolverProc; | 28 class ScopedDefaultHostResolverProc; |
27 } | 29 } |
28 | 30 |
29 // Live sync tests are allowed to run for up to 5 minutes. | 31 // Live sync tests are allowed to run for up to 5 minutes. |
30 const int kTestTimeoutInMS = 300000; | 32 const int kTestTimeoutInMS = 300000; |
31 | 33 |
32 // This is the base class for integration tests for all sync data types. Derived | 34 // This is the base class for integration tests for all sync data types. Derived |
33 // classes must be defined for each sync data type. Individual tests are defined | 35 // classes must be defined for each sync data type. Individual tests are defined |
34 // using the IN_PROC_BROWSER_TEST_F macro. | 36 // using the IN_PROC_BROWSER_TEST_F macro. |
35 class LiveSyncTest : public InProcessBrowserTest { | 37 class LiveSyncTest : public InProcessBrowserTest { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // Returns a pointer to the sync profile that is used to verify changes to | 115 // Returns a pointer to the sync profile that is used to verify changes to |
114 // individual sync profiles. Callee owns the object and manages its lifetime. | 116 // individual sync profiles. Callee owns the object and manages its lifetime. |
115 Profile* verifier(); | 117 Profile* verifier(); |
116 | 118 |
117 // Initializes sync clients and profiles but does not sync any of them. | 119 // Initializes sync clients and profiles but does not sync any of them. |
118 virtual bool SetupClients(); | 120 virtual bool SetupClients(); |
119 | 121 |
120 // Initializes sync clients and profiles if required and syncs each of them. | 122 // Initializes sync clients and profiles if required and syncs each of them. |
121 virtual bool SetupSync(); | 123 virtual bool SetupSync(); |
122 | 124 |
| 125 // Disable outgoing network connections for the given profile. |
| 126 virtual void DisableNetwork(Profile* profile); |
| 127 |
| 128 // Enable outgoing network connections for the given profile. |
| 129 virtual void EnableNetwork(Profile* profile); |
| 130 |
| 131 // Configure mock server with test's options. |
| 132 virtual bool EnsureSyncServerConfiguration(); |
| 133 |
123 protected: | 134 protected: |
124 // InProcessBrowserTest override. Destroys all the sync clients and sync | 135 // InProcessBrowserTest override. Destroys all the sync clients and sync |
125 // profiles created by a test. | 136 // profiles created by a test. |
126 virtual void CleanUpOnMainThread(); | 137 virtual void CleanUpOnMainThread(); |
127 | 138 |
128 // InProcessBrowserTest override. Changes behavior of the default host | 139 // InProcessBrowserTest override. Changes behavior of the default host |
129 // resolver to avoid DNS lookup errors. | 140 // resolver to avoid DNS lookup errors. |
130 virtual void SetUpInProcessBrowserTestFixture(); | 141 virtual void SetUpInProcessBrowserTestFixture(); |
131 | 142 |
132 // InProcessBrowserTest override. Resets the host resolver its default | 143 // InProcessBrowserTest override. Resets the host resolver its default |
(...skipping 13 matching lines...) Expand all Loading... |
146 // Helper to ProfileManager::CreateProfile that handles path creation. | 157 // Helper to ProfileManager::CreateProfile that handles path creation. |
147 static Profile* MakeProfile(const FilePath::StringType name); | 158 static Profile* MakeProfile(const FilePath::StringType name); |
148 | 159 |
149 // Helper method used to create a local python test server. | 160 // Helper method used to create a local python test server. |
150 virtual void SetUpLocalTestServer(); | 161 virtual void SetUpLocalTestServer(); |
151 | 162 |
152 // Helper method used to destroy the local python test server if one was | 163 // Helper method used to destroy the local python test server if one was |
153 // created. | 164 // created. |
154 virtual void TearDownLocalTestServer(); | 165 virtual void TearDownLocalTestServer(); |
155 | 166 |
| 167 // Used to disable and enable network connectivity by providing and |
| 168 // clearing an invalid proxy configuration. |
| 169 void SetProxyConfig(URLRequestContextGetter* context, |
| 170 const net::ProxyConfig& proxy_config); |
| 171 |
| 172 // Sends configuration options to the mock sync server. |
| 173 bool ConfigureSyncServer(const std::string& name, const std::string& value); |
| 174 |
156 // Used to differentiate between single-client, two-client, multi-client and | 175 // Used to differentiate between single-client, two-client, multi-client and |
157 // many-client tests. | 176 // many-client tests. |
158 TestType test_type_; | 177 TestType test_type_; |
159 | 178 |
160 // Number of sync clients that will be created by a test. | 179 // Number of sync clients that will be created by a test. |
161 int num_clients_; | 180 int num_clients_; |
162 | 181 |
163 // Collection of sync profiles used by a test. A sync profile maintains sync | 182 // Collection of sync profiles used by a test. A sync profile maintains sync |
164 // data contained within its own subdirectory under the chrome user data | 183 // data contained within its own subdirectory under the chrome user data |
165 // directory. | 184 // directory. |
(...skipping 17 matching lines...) Expand all Loading... |
183 | 202 |
184 // Sync integration tests need to make live DNS requests for access to | 203 // Sync integration tests need to make live DNS requests for access to |
185 // GAIA and sync server URLs under google.com. We use a scoped version | 204 // GAIA and sync server URLs under google.com. We use a scoped version |
186 // to override the default resolver while the test is active. | 205 // to override the default resolver while the test is active. |
187 scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_; | 206 scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_; |
188 | 207 |
189 DISALLOW_COPY_AND_ASSIGN(LiveSyncTest); | 208 DISALLOW_COPY_AND_ASSIGN(LiveSyncTest); |
190 }; | 209 }; |
191 | 210 |
192 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ | 211 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ |
OLD | NEW |