Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/test/live_sync/live_sync_test.h

Issue 2840034: Incorporating feedback from C++ readability review. (Closed)
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/live_sync/live_sync_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 7
8 #include "chrome/test/in_process_browser_test.h" 8 #include "chrome/test/in_process_browser_test.h"
9 9
10 #include "base/basictypes.h"
11 #include "base/scoped_ptr.h"
10 #include "base/scoped_vector.h" 12 #include "base/scoped_vector.h"
11 #include "chrome/test/live_sync/profile_sync_service_test_harness.h" 13 #include "chrome/test/live_sync/profile_sync_service_test_harness.h"
12 #include "net/base/mock_host_resolver.h" 14 #include "net/base/mock_host_resolver.h"
13 #include "net/socket/ssl_test_util.h" 15 #include "net/socket/ssl_test_util.h"
14 16
15 #include <string> 17 #include <string>
16 18
19 class CommandLine;
17 class Profile; 20 class Profile;
18 class CommandLine;
19 21
20 namespace net { 22 namespace net {
21 class ScopedDefaultHostResolverProc; 23 class ScopedDefaultHostResolverProc;
22 } 24 }
23 25
24 namespace switches {
25 extern const wchar_t kSyncUserForTest[];
26 extern const wchar_t kSyncPasswordForTest[];
27 }
28
29 // Live sync tests are allowed to run for up to 5 minutes. 26 // Live sync tests are allowed to run for up to 5 minutes.
30 const int kTestTimeoutInMS = 300000; 27 const int kTestTimeoutInMS = 300000;
31 28
32 // This is the base class for integration tests for all sync data types. Derived 29 // 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 30 // classes must be defined for each sync data type. Individual tests are defined
34 // using the IN_PROC_BROWSER_TEST_F macro. 31 // using the IN_PROC_BROWSER_TEST_F macro.
35 class LiveSyncTest : public InProcessBrowserTest { 32 class LiveSyncTest : public InProcessBrowserTest {
36 public: 33 public:
37 // The different types of live sync tests that can be implemented. 34 // The different types of live sync tests that can be implemented.
38 enum TestType { 35 enum TestType {
39 // Tests where only one client profile is synced with the server. Typically 36 // Tests where only one client profile is synced with the server. Typically
40 // sanity level tests. 37 // sanity level tests.
41 SINGLE_CLIENT, 38 SINGLE_CLIENT,
42 39
43 // Tests where two client profiles are synced with the server. Typically 40 // Tests where two client profiles are synced with the server. Typically
44 // functionality level tests. 41 // functionality level tests.
45 TWO_CLIENT, 42 TWO_CLIENT,
46 43
47 // Tests where three client profiles are synced with the server. Typically, 44 // Tests where three or more client profiles are synced with the server.
48 // these tests create client side races and verify that sync works. 45 // Typically, these tests create client side races and verify that sync
46 // works.
49 MULTIPLE_CLIENT, 47 MULTIPLE_CLIENT,
50 48
51 // Tests where several client profiles are synced with the server. Only used 49 // Tests where several client profiles are synced with the server. Only used
52 // by stress tests. 50 // by stress tests.
53 MANY_CLIENT 51 MANY_CLIENT
54 }; 52 };
55 53
56 // A LiveSyncTest must be associated with a particular test type. 54 // A LiveSyncTest must be associated with a particular test type.
57 explicit LiveSyncTest(TestType test_type) 55 explicit LiveSyncTest(TestType test_type)
58 : test_type_(test_type), 56 : test_type_(test_type),
(...skipping 23 matching lines...) Expand all
82 80
83 virtual ~LiveSyncTest() {} 81 virtual ~LiveSyncTest() {}
84 82
85 // Validates command line parameters and creates a local python test server if 83 // Validates command line parameters and creates a local python test server if
86 // specified. 84 // specified.
87 virtual void SetUp(); 85 virtual void SetUp();
88 86
89 // Brings down local python test server if one was created. 87 // Brings down local python test server if one was created.
90 virtual void TearDown(); 88 virtual void TearDown();
91 89
92 // Append command line flag to enable sync. 90 // Appends command line flag to enable sync.
93 virtual void SetUpCommandLine(CommandLine* command_line) {} 91 virtual void SetUpCommandLine(CommandLine* command_line) {}
94 92
95 // Helper to ProfileManager::CreateProfile that handles path creation.
96 static Profile* MakeProfile(const FilePath::StringType name);
97
98 // Used to get the number of sync clients used by a test. 93 // Used to get the number of sync clients used by a test.
99 int num_clients() { return num_clients_; } 94 int num_clients() { return num_clients_; }
100 95
101 // Used to access a particular sync profile. 96 // Returns a pointer to a particular sync profile. Callee owns the object
97 // and manages its lifetime.
102 Profile* GetProfile(int index); 98 Profile* GetProfile(int index);
103 99
104 // Used to access a particular sync client. 100 // Returns a pointer to a particular sync client. Callee owns the object
101 // and manages its lifetime.
105 ProfileSyncServiceTestHarness* GetClient(int index); 102 ProfileSyncServiceTestHarness* GetClient(int index);
106 103
107 // Used to verify changes to individual sync profiles. 104 // Returns a pointer to the sync profile that is used to verify changes to
105 // individual sync profiles. Callee owns the object and manages its lifetime.
108 Profile* verifier(); 106 Profile* verifier();
109 107
110 // Initializes sync clients and profiles but does not sync any of them. 108 // Initializes sync clients and profiles but does not sync any of them.
111 virtual bool SetupClients(); 109 virtual bool SetupClients();
112 110
113 // Initializes sync clients and profiles if required and syncs each of them. 111 // Initializes sync clients and profiles if required and syncs each of them.
114 virtual bool SetupSync(); 112 virtual bool SetupSync();
115 113
116 protected: 114 protected:
117 // InProcessBrowserTest override. Destroys all the sync clients and sync 115 // InProcessBrowserTest override. Destroys all the sync clients and sync
118 // profiles created by a test. 116 // profiles created by a test.
119 virtual void CleanUpOnMainThread(); 117 virtual void CleanUpOnMainThread();
120 118
121 // InProcessBrowserTest override. Changes behavior of the default host 119 // InProcessBrowserTest override. Changes behavior of the default host
122 // resolver to avoid DNS lookup errors. 120 // resolver to avoid DNS lookup errors.
123 virtual void SetUpInProcessBrowserTestFixture(); 121 virtual void SetUpInProcessBrowserTestFixture();
124 122
125 // InProcessBrowserTest override. Resets the host resolver its default 123 // InProcessBrowserTest override. Resets the host resolver its default
126 // behavior. 124 // behavior.
127 virtual void TearDownInProcessBrowserTestFixture(); 125 virtual void TearDownInProcessBrowserTestFixture();
128 126
129 // GAIA account used by the test case. 127 // GAIA account used by the test case.
130 std::string username_; 128 std::string username_;
131 129
132 // GAIA password used by the test case. 130 // GAIA password used by the test case.
133 std::string password_; 131 std::string password_;
134 132
135 private: 133 private:
134 // Helper to ProfileManager::CreateProfile that handles path creation.
135 static Profile* MakeProfile(const FilePath::StringType name);
136
136 // Helper method used to create a local python test server. 137 // Helper method used to create a local python test server.
137 virtual void SetUpLocalTestServer(); 138 virtual void SetUpLocalTestServer();
138 139
139 // Helper method used to destroy the local python test server if one was 140 // Helper method used to destroy the local python test server if one was
140 // created. 141 // created.
141 virtual void TearDownLocalTestServer(); 142 virtual void TearDownLocalTestServer();
142 143
143 // Used to differentiate between single-client, two-client, multi-client and 144 // Used to differentiate between single-client, two-client, multi-client and
144 // many-client tests. 145 // many-client tests.
145 TestType test_type_; 146 TestType test_type_;
(...skipping 24 matching lines...) Expand all
170 171
171 // Sync integration tests need to make live DNS requests for access to 172 // Sync integration tests need to make live DNS requests for access to
172 // GAIA and sync server URLs under google.com. We use a scoped version 173 // GAIA and sync server URLs under google.com. We use a scoped version
173 // to override the default resolver while the test is active. 174 // to override the default resolver while the test is active.
174 scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_; 175 scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_;
175 176
176 DISALLOW_COPY_AND_ASSIGN(LiveSyncTest); 177 DISALLOW_COPY_AND_ASSIGN(LiveSyncTest);
177 }; 178 };
178 179
179 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ 180 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/test/live_sync/live_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698