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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 // of sync server "providers" -- a script that could locate (or allocate) | 51 // of sync server "providers" -- a script that could locate (or allocate) |
52 // a sync server instance, possibly on some remote host. The provider | 52 // a sync server instance, possibly on some remote host. The provider |
53 // would be invoked before each test. | 53 // would be invoked before each test. |
54 if (!cl->HasSwitch(switches::kSyncServiceURL)) | 54 if (!cl->HasSwitch(switches::kSyncServiceURL)) |
55 SetUpLocalTestServer(); | 55 SetUpLocalTestServer(); |
56 | 56 |
57 // Yield control back to the InProcessBrowserTest framework. | 57 // Yield control back to the InProcessBrowserTest framework. |
58 InProcessBrowserTest::SetUp(); | 58 InProcessBrowserTest::SetUp(); |
59 } | 59 } |
60 | 60 |
| 61 virtual void TearDown() { |
| 62 // Allow the InProcessBrowserTest framework to perform its tear down. |
| 63 InProcessBrowserTest::TearDown(); |
| 64 |
| 65 // Stop the local test sync server if one was used. |
| 66 if (started_local_test_server_) |
| 67 TearDownLocalTestServer(); |
| 68 } |
| 69 |
61 virtual void SetUpLocalTestServer() { | 70 virtual void SetUpLocalTestServer() { |
62 bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, | 71 bool success = server_.Start(net::TestServerLauncher::ProtoHTTP, |
63 server_.kHostName, server_.kOKHTTPSPort, | 72 server_.kHostName, server_.kOKHTTPSPort, |
64 FilePath(), FilePath(), std::wstring()); | 73 FilePath(), FilePath(), std::wstring()); |
65 ASSERT_TRUE(success); | 74 ASSERT_TRUE(success); |
66 | 75 |
| 76 started_local_test_server_ = true; |
| 77 |
67 CommandLine* cl = CommandLine::ForCurrentProcess(); | 78 CommandLine* cl = CommandLine::ForCurrentProcess(); |
68 cl->AppendSwitchWithValue(switches::kSyncServiceURL, | 79 cl->AppendSwitchWithValue(switches::kSyncServiceURL, |
69 StringPrintf("http://%s:%d/chromiumsync", server_.kHostName, | 80 StringPrintf("http://%s:%d/chromiumsync", server_.kHostName, |
70 server_.kOKHTTPSPort)); | 81 server_.kOKHTTPSPort)); |
71 } | 82 } |
72 | 83 |
| 84 virtual void TearDownLocalTestServer() { |
| 85 bool success = server_.Stop(); |
| 86 ASSERT_TRUE(success); |
| 87 } |
| 88 |
73 // Append command line flag to enable sync. | 89 // Append command line flag to enable sync. |
74 virtual void SetUpCommandLine(CommandLine* command_line) { | 90 virtual void SetUpCommandLine(CommandLine* command_line) { |
75 } | 91 } |
76 | 92 |
77 // Helper to get a handle on a bookmark in |m| when the url is known to be | 93 // Helper to get a handle on a bookmark in |m| when the url is known to be |
78 // unique. | 94 // unique. |
79 static const BookmarkNode* GetByUniqueURL(BookmarkModel* m, const GURL& url); | 95 static const BookmarkNode* GetByUniqueURL(BookmarkModel* m, const GURL& url); |
80 | 96 |
81 // Helper to ProfileManager::CreateProfile that handles path creation. | 97 // Helper to ProfileManager::CreateProfile that handles path creation. |
82 static Profile* MakeProfile(const FilePath::CharType* name); | 98 static Profile* MakeProfile(const FilePath::CharType* name); |
(...skipping 10 matching lines...) Expand all Loading... |
93 virtual void SetUpInProcessBrowserTestFixture(); | 109 virtual void SetUpInProcessBrowserTestFixture(); |
94 virtual void TearDownInProcessBrowserTestFixture(); | 110 virtual void TearDownInProcessBrowserTestFixture(); |
95 | 111 |
96 private: | 112 private: |
97 // LiveBookmarksSyncTests need to make live DNS requests for access to | 113 // LiveBookmarksSyncTests need to make live DNS requests for access to |
98 // GAIA and sync server URLs under google.com. We use a scoped version | 114 // GAIA and sync server URLs under google.com. We use a scoped version |
99 // to override the default resolver while the test is active. | 115 // to override the default resolver while the test is active. |
100 scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_; | 116 scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_; |
101 | 117 |
102 net::TestServerLauncher server_; | 118 net::TestServerLauncher server_; |
| 119 bool started_local_test_server_; |
103 | 120 |
104 DISALLOW_COPY_AND_ASSIGN(LiveSyncTest); | 121 DISALLOW_COPY_AND_ASSIGN(LiveSyncTest); |
105 }; | 122 }; |
106 | 123 |
107 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ | 124 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ |
OLD | NEW |