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