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

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

Issue 1763023: Re-apply http://codereview.chromium.org/1622012 (Closed)
Patch Set: Add missing files (I thought git would do that) Created 10 years, 7 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
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 <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/in_process_browser_test.h" 13 #include "chrome/test/in_process_browser_test.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "net/socket/ssl_test_util.h"
15 16
16 class BookmarkModel; 17 class BookmarkModel;
17 class BookmarkNode; 18 class BookmarkNode;
18 class Profile; 19 class Profile;
19 namespace net { 20 namespace net {
20 class ScopedDefaultHostResolverProc; 21 class ScopedDefaultHostResolverProc;
21 } 22 }
22 23
23 namespace switches { 24 namespace switches {
24 extern const wchar_t kSyncUserForTest[]; 25 extern const wchar_t kSyncUserForTest[];
(...skipping 13 matching lines...) Expand all
38 // available. But we can verify our command line parameters and fail 39 // available. But we can verify our command line parameters and fail
39 // early. 40 // early.
40 const CommandLine* cl = CommandLine::ForCurrentProcess(); 41 const CommandLine* cl = CommandLine::ForCurrentProcess();
41 username_ = WideToUTF8(cl->GetSwitchValue(switches::kSyncUserForTest)); 42 username_ = WideToUTF8(cl->GetSwitchValue(switches::kSyncUserForTest));
42 password_ = WideToUTF8(cl->GetSwitchValue(switches::kSyncPasswordForTest)); 43 password_ = WideToUTF8(cl->GetSwitchValue(switches::kSyncPasswordForTest));
43 ASSERT_FALSE(username_.empty()) << "Can't run live server test " 44 ASSERT_FALSE(username_.empty()) << "Can't run live server test "
44 << "without specifying --" << switches::kSyncUserForTest; 45 << "without specifying --" << switches::kSyncUserForTest;
45 ASSERT_FALSE(password_.empty()) << "Can't run live server test " 46 ASSERT_FALSE(password_.empty()) << "Can't run live server test "
46 << "without specifying --" << switches::kSyncPasswordForTest; 47 << "without specifying --" << switches::kSyncPasswordForTest;
47 48
49 // Unless a sync server was explicitly provided, run a test one locally.
50 // TODO(ncarter): It might be better to allow the user to specify a choice
51 // of sync server "providers" -- a script that could locate (or allocate)
52 // a sync server instance, possibly on some remote host. The provider
53 // would be invoked before each test.
54 if (!cl->HasSwitch(switches::kSyncServiceURL))
55 SetUpLocalTestServer();
56
48 // Yield control back to the InProcessBrowserTest framework. 57 // Yield control back to the InProcessBrowserTest framework.
49 InProcessBrowserTest::SetUp(); 58 InProcessBrowserTest::SetUp();
50 } 59 }
51 60
61 virtual void SetUpLocalTestServer() {
62 bool success = server_.Start(net::TestServerLauncher::ProtoHTTP,
63 server_.kHostName, server_.kOKHTTPSPort,
64 FilePath(), FilePath(), std::wstring());
65 ASSERT_TRUE(success);
66
67 CommandLine* cl = CommandLine::ForCurrentProcess();
68 cl->AppendSwitchWithValue(switches::kSyncServiceURL,
69 StringPrintf("http://%s:%d/chromiumsync", server_.kHostName,
70 server_.kOKHTTPSPort));
71 }
72
52 // Append command line flag to enable sync. 73 // Append command line flag to enable sync.
53 virtual void SetUpCommandLine(CommandLine* command_line) { 74 virtual void SetUpCommandLine(CommandLine* command_line) {
54 } 75 }
55 76
56 // Helper to get a handle on a bookmark in |m| when the url is known to be 77 // Helper to get a handle on a bookmark in |m| when the url is known to be
57 // unique. 78 // unique.
58 static const BookmarkNode* GetByUniqueURL(BookmarkModel* m, const GURL& url); 79 static const BookmarkNode* GetByUniqueURL(BookmarkModel* m, const GURL& url);
59 80
60 // Helper to ProfileManager::CreateProfile that handles path creation. 81 // Helper to ProfileManager::CreateProfile that handles path creation.
61 static Profile* MakeProfile(const FilePath::CharType* name); 82 static Profile* MakeProfile(const FilePath::CharType* name);
62 83
63 // Utility to block (by running the current MessageLoop) until the model has 84 // Utility to block (by running the current MessageLoop) until the model has
64 // loaded. Note this is required instead of using m->BlockTillLoaded, as that 85 // loaded. Note this is required instead of using m->BlockTillLoaded, as that
65 // cannot be called from the main thread (deadlock will occur). 86 // cannot be called from the main thread (deadlock will occur).
66 static void BlockUntilLoaded(BookmarkModel* m); 87 static void BlockUntilLoaded(BookmarkModel* m);
67 88
68 protected: 89 protected:
69 std::string username_; 90 std::string username_;
70 std::string password_; 91 std::string password_;
71 92
72 virtual void SetUpInProcessBrowserTestFixture(); 93 virtual void SetUpInProcessBrowserTestFixture();
73 virtual void TearDownInProcessBrowserTestFixture(); 94 virtual void TearDownInProcessBrowserTestFixture();
74 95
75 private: 96 private:
76 // LiveBookmarksSyncTests need to make live DNS requests for access to 97 // LiveBookmarksSyncTests need to make live DNS requests for access to
77 // GAIA and sync server URLs under google.com. We use a scoped version 98 // GAIA and sync server URLs under google.com. We use a scoped version
78 // to override the default resolver while the test is active. 99 // to override the default resolver while the test is active.
79 scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_; 100 scoped_ptr<net::ScopedDefaultHostResolverProc> mock_host_resolver_override_;
80 101
102 net::TestServerLauncher server_;
103
81 DISALLOW_COPY_AND_ASSIGN(LiveSyncTest); 104 DISALLOW_COPY_AND_ASSIGN(LiveSyncTest);
82 }; 105 };
83 106
84 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_ 107 #endif // CHROME_TEST_LIVE_SYNC_LIVE_SYNC_TEST_H_
OLDNEW
« no previous file with comments | « chrome/test/in_process_browser_test.cc ('k') | chrome/test/live_sync/two_client_live_bookmarks_sync_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698