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

Unified Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 11971025: [sync] Divorce python sync test server chromiumsync.py from testserver.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/automation/testing_automation_provider.cc
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 436420e85279ccabfe023f2fec87b79535cefaae..662de60796ca215d8b8a5ca5db88865429be3f6f 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -1,4 +1,4 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
+// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -84,8 +84,6 @@
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/sessions/session_tab_helper.h"
-#include "chrome/browser/sync/profile_sync_service.h"
-#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
#include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
#include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
@@ -1910,19 +1908,6 @@ void TestingAutomationProvider::BuildJSONHandlerMaps() {
browser_handler_map_["WaitForNotificationCount"] =
&TestingAutomationProvider::WaitForNotificationCount;
- browser_handler_map_["SignInToSync"] =
- &TestingAutomationProvider::SignInToSync;
- browser_handler_map_["GetSyncInfo"] =
- &TestingAutomationProvider::GetSyncInfo;
- browser_handler_map_["AwaitFullSyncCompletion"] =
- &TestingAutomationProvider::AwaitFullSyncCompletion;
- browser_handler_map_["AwaitSyncRestart"] =
- &TestingAutomationProvider::AwaitSyncRestart;
- browser_handler_map_["EnableSyncForDatatypes"] =
- &TestingAutomationProvider::EnableSyncForDatatypes;
- browser_handler_map_["DisableSyncForDatatypes"] =
- &TestingAutomationProvider::DisableSyncForDatatypes;
-
browser_handler_map_["GetNTPInfo"] =
&TestingAutomationProvider::GetNTPInfo;
browser_handler_map_["RemoveNTPMostVisitedThumbnail"] =
@@ -4178,237 +4163,6 @@ void TestingAutomationProvider::AppendSwitchASCIIToCommandLine(
reply.SendSuccess(NULL);
}
-// Sample json output: { "success": true }
-void TestingAutomationProvider::SignInToSync(Browser* browser,
- DictionaryValue* args,
- IPC::Message* reply_message) {
- AutomationJSONReply reply(this, reply_message);
- std::string username;
- std::string password;
- if (!args->GetString("username", &username) ||
- !args->GetString("password", &password)) {
- reply.SendError("Invalid or missing args");
- return;
- }
- if (sync_waiter_.get() == NULL) {
- sync_waiter_.reset(new ProfileSyncServiceHarness(
- browser->profile(), username, password));
- } else {
- sync_waiter_->SetCredentials(username, password);
- }
- if (sync_waiter_->SetupSync()) {
- scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- return_value->SetBoolean("success", true);
- reply.SendSuccess(return_value.get());
- } else {
- reply.SendError("Signing in to sync was unsuccessful");
- }
-}
-
-// Sample json output:
-// {u'summary': u'SYNC DISABLED'}
-//
-// { u'last synced': u'Just now',
-// u'sync url': u'clients4.google.com',
-// u'updates received': 42,
-// u'synced datatypes': [ u'Bookmarks',
-// u'Preferences',
-// u'Passwords',
-// u'Autofill',
-// u'Themes',
-// u'Extensions',
-// u'Apps']}
-void TestingAutomationProvider::GetSyncInfo(Browser* browser,
- DictionaryValue* args,
- IPC::Message* reply_message) {
- AutomationJSONReply reply(this, reply_message);
- DictionaryValue* sync_info = new DictionaryValue;
- scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- if (sync_waiter_.get() == NULL) {
- sync_waiter_.reset(
- ProfileSyncServiceHarness::CreateAndAttach(browser->profile()));
- }
- if (!sync_waiter_->IsSyncAlreadySetup()) {
- sync_info->SetString("summary", "SYNC DISABLED");
- } else {
- ProfileSyncService* service = sync_waiter_->service();
- ProfileSyncService::Status status = sync_waiter_->GetStatus();
- sync_info->SetString("sync url", service->sync_service_url().host());
- sync_info->SetString("last synced", service->GetLastSyncedTimeString());
- sync_info->SetInteger("updates received", status.updates_received);
- ListValue* synced_datatype_list = new ListValue;
- const syncer::ModelTypeSet synced_datatypes =
- service->GetPreferredDataTypes();
- for (syncer::ModelTypeSet::Iterator it = synced_datatypes.First();
- it.Good(); it.Inc()) {
- synced_datatype_list->Append(
- new StringValue(syncer::ModelTypeToString(it.Get())));
- }
- sync_info->Set("synced datatypes", synced_datatype_list);
- }
- return_value->Set("sync_info", sync_info);
- reply.SendSuccess(return_value.get());
-}
-
-// Sample json output: { "success": true }
-void TestingAutomationProvider::AwaitFullSyncCompletion(
- Browser* browser,
- DictionaryValue* args,
- IPC::Message* reply_message) {
- AutomationJSONReply reply(this, reply_message);
- if (sync_waiter_.get() == NULL) {
- sync_waiter_.reset(
- ProfileSyncServiceHarness::CreateAndAttach(browser->profile()));
- }
- if (!sync_waiter_->IsSyncAlreadySetup()) {
- reply.SendError("Not signed in to sync");
- return;
- }
- // Ensure that the profile sync service and sync backend host are initialized
- // before waiting for sync cycle completion. In cases where the browser is
- // restarted with sync enabled, these operations may still be in flight.
- if (ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- browser->profile()) == NULL) {
- reply.SendError("ProfileSyncService initialization failed.");
- return;
- }
- if (!sync_waiter_->service()->sync_initialized() &&
- !sync_waiter_->AwaitBackendInitialized()) {
- reply.SendError("Sync backend host initialization failed.");
- return;
- }
- if (!sync_waiter_->AwaitFullSyncCompletion("Waiting for sync cycle")) {
- reply.SendError("Sync cycle did not complete.");
- return;
- }
- scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- return_value->SetBoolean("success", true);
- reply.SendSuccess(return_value.get());
-}
-
-// Sample json output: { "success": true }
-void TestingAutomationProvider::AwaitSyncRestart(
- Browser* browser,
- DictionaryValue* args,
- IPC::Message* reply_message) {
- AutomationJSONReply reply(this, reply_message);
- if (sync_waiter_.get() == NULL) {
- sync_waiter_.reset(
- ProfileSyncServiceHarness::CreateAndAttach(browser->profile()));
- }
- if (!sync_waiter_->IsSyncAlreadySetup()) {
- reply.SendError("Not signed in to sync");
- return;
- }
- if (ProfileSyncServiceFactory::GetInstance()->GetForProfile(
- browser->profile()) == NULL) {
- reply.SendError("ProfileSyncService initialization failed.");
- return;
- }
- if (!sync_waiter_->AwaitSyncRestart()) {
- reply.SendError("Sync did not successfully restart.");
- return;
- }
- scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- return_value->SetBoolean("success", true);
- reply.SendSuccess(return_value.get());
-}
-
-// Refer to EnableSyncForDatatypes() in chrome/test/pyautolib/pyauto.py for
-// sample json input. Sample json output: { "success": true }
-void TestingAutomationProvider::EnableSyncForDatatypes(
- Browser* browser,
- DictionaryValue* args,
- IPC::Message* reply_message) {
- AutomationJSONReply reply(this, reply_message);
- if (sync_waiter_.get() == NULL) {
- sync_waiter_.reset(
- ProfileSyncServiceHarness::CreateAndAttach(browser->profile()));
- }
- if (!sync_waiter_->IsSyncAlreadySetup()) {
- reply.SendError("Not signed in to sync");
- return;
- }
- ListValue* datatypes = NULL;
- if (!args->GetList("datatypes", &datatypes)) {
- reply.SendError("Invalid or missing args");
- return;
- }
- std::string first_datatype;
- datatypes->GetString(0, &first_datatype);
- if (first_datatype == "All") {
- sync_waiter_->EnableSyncForAllDatatypes();
- } else {
- int num_datatypes = datatypes->GetSize();
- for (int i = 0; i < num_datatypes; ++i) {
- std::string datatype_string;
- datatypes->GetString(i, &datatype_string);
- syncer::ModelType datatype =
- syncer::ModelTypeFromString(datatype_string);
- if (datatype == syncer::UNSPECIFIED) {
- AutomationJSONReply(this, reply_message).SendError(StringPrintf(
- "Invalid datatype string: %s.", datatype_string.c_str()));
- return;
- }
- sync_waiter_->EnableSyncForDatatype(datatype);
- sync_waiter_->AwaitFullSyncCompletion(StringPrintf(
- "Enabling datatype: %s", datatype_string.c_str()));
- }
- }
- scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- return_value->SetBoolean("success", true);
- reply.SendSuccess(return_value.get());
-}
-
-// Refer to DisableSyncForDatatypes() in chrome/test/pyautolib/pyauto.py for
-// sample json input. Sample json output: { "success": true }
-void TestingAutomationProvider::DisableSyncForDatatypes(
- Browser* browser,
- DictionaryValue* args,
- IPC::Message* reply_message) {
- AutomationJSONReply reply(this, reply_message);
- if (sync_waiter_.get() == NULL) {
- sync_waiter_.reset(
- ProfileSyncServiceHarness::CreateAndAttach(browser->profile()));
- }
- if (!sync_waiter_->IsSyncAlreadySetup()) {
- reply.SendError("Not signed in to sync");
- return;
- }
- ListValue* datatypes = NULL;
- if (!args->GetList("datatypes", &datatypes)) {
- reply.SendError("Invalid or missing args");
- return;
- }
- std::string first_datatype;
- if (!datatypes->GetString(0, &first_datatype)) {
- reply.SendError("Invalid or missing string");
- return;
- }
- if (first_datatype == "All") {
- sync_waiter_->DisableSyncForAllDatatypes();
- } else {
- int num_datatypes = datatypes->GetSize();
- for (int i = 0; i < num_datatypes; i++) {
- std::string datatype_string;
- datatypes->GetString(i, &datatype_string);
- syncer::ModelType datatype =
- syncer::ModelTypeFromString(datatype_string);
- if (datatype == syncer::UNSPECIFIED) {
- AutomationJSONReply(this, reply_message).SendError(StringPrintf(
- "Invalid datatype string: %s.", datatype_string.c_str()));
- return;
- }
- sync_waiter_->DisableSyncForDatatype(datatype);
- sync_waiter_->AwaitFullSyncCompletion(StringPrintf(
- "Disabling datatype: %s", datatype_string.c_str()));
- }
- scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
- return_value->SetBoolean("success", true);
- reply.SendSuccess(return_value.get());
- }
-}
-
// Refer to GetAllNotifications() in chrome/test/pyautolib/pyauto.py for
// sample json input/output.
void TestingAutomationProvider::GetAllNotifications(
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/browser/safe_browsing/safe_browsing_testserver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698