Commit 158e57cd authored by rsimha@chromium.org's avatar rsimha@chromium.org

Disable background network access in sync integration tests

Now that the sync integration tests are designed to be self-contained
and not rely on external network resources like GAIA, we need to ensure
that background network access for things like auto update is disabled.

This patch adds the --disable-background-networking command line switch
to the sync integration test framework.

BUG=69469, 53931
TEST=sync_integration_tests

Review URL: http://codereview.chromium.org/6282001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71338 0039d316-1c4b-4281-b951-d872f2087c98
parent 3801e985
......@@ -108,9 +108,9 @@ void LiveExtensionsSyncTestBase::InstallExtension(
void LiveExtensionsSyncTestBase::InstallAllPendingExtensions(
Profile* profile) {
// TODO(akalin): Mock out the servers that the extensions
// auto-update mechanism talk to so as to more closely match what
// actually happens.
// TODO(akalin): Mock out the servers that the extensions auto-update
// mechanism talk to so as to more closely match what actually happens.
// Background networking will need to be re-enabled for extensions tests.
// We make a copy here since InstallExtension() removes the
// extension from the extensions service's copy.
......
......@@ -131,16 +131,11 @@ LiveSyncTest::LiveSyncTest(TestType test_type)
}
void LiveSyncTest::SetUp() {
// At this point, the browser hasn't been launched, and no services are
// available. But we can verify our command line parameters and fail
// early.
CommandLine* cl = CommandLine::ForCurrentProcess();
if (cl->HasSwitch(switches::kPasswordFileForTest)) {
ReadPasswordFile();
} else if (cl->HasSwitch(switches::kSyncUserForTest) &&
cl->HasSwitch(switches::kSyncPasswordForTest)) {
// Read GAIA credentials from the "--sync-XXX-for-test" command line
// parameters.
username_ = cl->GetSwitchValueASCII(switches::kSyncUserForTest);
password_ = cl->GetSwitchValueASCII(switches::kSyncPasswordForTest);
} else {
......@@ -149,21 +144,6 @@ void LiveSyncTest::SetUp() {
if (username_.empty() || password_.empty())
LOG(FATAL) << "Cannot run sync tests without GAIA credentials.";
// TODO(rsimha): Until we implement a fake Tango server against which tests
// can run, we need to set the --sync-notification-method to "p2p".
if (!cl->HasSwitch(switches::kSyncNotificationMethod))
cl->AppendSwitchASCII(switches::kSyncNotificationMethod, "p2p");
// TODO(sync): Remove this once sessions sync is enabled by default.
if (!cl->HasSwitch(switches::kEnableSyncSessions)) {
cl->AppendSwitch(switches::kEnableSyncSessions);
}
// TODO(sync): Remove this once passwords sync is enabled by default.
if (!cl->HasSwitch(switches::kEnableSyncPasswords)) {
cl->AppendSwitch(switches::kEnableSyncPasswords);
}
// Mock the Mac Keychain service. The real Keychain can block on user input.
#if defined(OS_MACOSX)
Encryptor::UseMockKeychain(true);
......@@ -188,6 +168,25 @@ void LiveSyncTest::TearDown() {
URLFetcher::set_factory(NULL);
}
void LiveSyncTest::SetUpCommandLine(CommandLine* cl) {
// TODO(rsimha): Until we implement a fake Tango server against which tests
// can run, we need to set the --sync-notification-method to "p2p".
if (!cl->HasSwitch(switches::kSyncNotificationMethod))
cl->AppendSwitchASCII(switches::kSyncNotificationMethod, "p2p");
// TODO(sync): Remove this once sessions sync is enabled by default.
if (!cl->HasSwitch(switches::kEnableSyncSessions))
cl->AppendSwitch(switches::kEnableSyncSessions);
// TODO(sync): Remove this once passwords sync is enabled by default.
if (!cl->HasSwitch(switches::kEnableSyncPasswords))
cl->AppendSwitch(switches::kEnableSyncPasswords);
// Disable non-essential access of external network resources.
if (!cl->HasSwitch(switches::kDisableBackgroundNetworking))
cl->AppendSwitch(switches::kDisableBackgroundNetworking);
}
// static
Profile* LiveSyncTest::MakeProfile(const FilePath::StringType name) {
FilePath path;
......
......@@ -67,8 +67,8 @@ class LiveSyncTest : public InProcessBrowserTest {
// Brings down local python test server if one was created.
virtual void TearDown();
// Appends command line flag to enable sync.
virtual void SetUpCommandLine(CommandLine* command_line) {}
// Sets up command line flags required for sync tests.
virtual void SetUpCommandLine(CommandLine* cl);
// Used to get the number of sync clients used by a test.
int num_clients() WARN_UNUSED_RESULT { return num_clients_; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment