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

Side by Side Diff: chrome/browser/automation/testing_automation_provider.cc

Issue 10913043: Convert the popups pyauto test to browser_tests. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #include "chrome/browser/sync/profile_sync_service.h" 88 #include "chrome/browser/sync/profile_sync_service.h"
89 #include "chrome/browser/sync/profile_sync_service_factory.h" 89 #include "chrome/browser/sync/profile_sync_service_factory.h"
90 #include "chrome/browser/themes/theme_service.h" 90 #include "chrome/browser/themes/theme_service.h"
91 #include "chrome/browser/themes/theme_service_factory.h" 91 #include "chrome/browser/themes/theme_service_factory.h"
92 #include "chrome/browser/translate/translate_infobar_delegate.h" 92 #include "chrome/browser/translate/translate_infobar_delegate.h"
93 #include "chrome/browser/translate/translate_tab_helper.h" 93 #include "chrome/browser/translate/translate_tab_helper.h"
94 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 94 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
95 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" 95 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h"
96 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" 96 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
97 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 97 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
98 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
99 #include "chrome/browser/ui/bookmarks/bookmark_bar.h" 98 #include "chrome/browser/ui/bookmarks/bookmark_bar.h"
100 #include "chrome/browser/ui/browser_commands.h" 99 #include "chrome/browser/ui/browser_commands.h"
101 #include "chrome/browser/ui/browser_finder.h" 100 #include "chrome/browser/ui/browser_finder.h"
102 #include "chrome/browser/ui/browser_instant_controller.h" 101 #include "chrome/browser/ui/browser_instant_controller.h"
103 #include "chrome/browser/ui/browser_list.h" 102 #include "chrome/browser/ui/browser_list.h"
104 #include "chrome/browser/ui/browser_tabstrip.h" 103 #include "chrome/browser/ui/browser_tabstrip.h"
105 #include "chrome/browser/ui/browser_window.h" 104 #include "chrome/browser/ui/browser_window.h"
106 #include "chrome/browser/ui/extensions/application_launch.h" 105 #include "chrome/browser/ui/extensions/application_launch.h"
107 #include "chrome/browser/ui/find_bar/find_bar.h" 106 #include "chrome/browser/ui/find_bar/find_bar.h"
107 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
108 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 108 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
109 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h" 109 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h"
110 #include "chrome/browser/ui/login/login_prompt.h" 110 #include "chrome/browser/ui/login/login_prompt.h"
111 #include "chrome/browser/ui/media_stream_infobar_delegate.h" 111 #include "chrome/browser/ui/media_stream_infobar_delegate.h"
112 #include "chrome/browser/ui/omnibox/location_bar.h" 112 #include "chrome/browser/ui/omnibox/location_bar.h"
113 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" 113 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
114 #include "chrome/browser/ui/omnibox/omnibox_view.h" 114 #include "chrome/browser/ui/omnibox/omnibox_view.h"
115 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h" 115 #include "chrome/browser/ui/search_engines/keyword_editor_controller.h"
116 #include "chrome/browser/ui/startup/startup_types.h" 116 #include "chrome/browser/ui/startup/startup_types.h"
117 #include "chrome/browser/ui/tab_contents/tab_contents.h" 117 #include "chrome/browser/ui/tab_contents/tab_contents.h"
(...skipping 1810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 browser_handler_map_["ImportSettings"] = 1928 browser_handler_map_["ImportSettings"] =
1929 &TestingAutomationProvider::ImportSettings; 1929 &TestingAutomationProvider::ImportSettings;
1930 1930
1931 browser_handler_map_["AddSavedPassword"] = 1931 browser_handler_map_["AddSavedPassword"] =
1932 &TestingAutomationProvider::AddSavedPassword; 1932 &TestingAutomationProvider::AddSavedPassword;
1933 browser_handler_map_["RemoveSavedPassword"] = 1933 browser_handler_map_["RemoveSavedPassword"] =
1934 &TestingAutomationProvider::RemoveSavedPassword; 1934 &TestingAutomationProvider::RemoveSavedPassword;
1935 browser_handler_map_["GetSavedPasswords"] = 1935 browser_handler_map_["GetSavedPasswords"] =
1936 &TestingAutomationProvider::GetSavedPasswords; 1936 &TestingAutomationProvider::GetSavedPasswords;
1937 1937
1938 browser_handler_map_["GetBlockedPopupsInfo"] =
1939 &TestingAutomationProvider::GetBlockedPopupsInfo;
1940 browser_handler_map_["UnblockAndLaunchBlockedPopup"] =
1941 &TestingAutomationProvider::UnblockAndLaunchBlockedPopup;
1942 handler_map_["ResetToDefaultTheme"] = 1938 handler_map_["ResetToDefaultTheme"] =
1943 &TestingAutomationProvider::ResetToDefaultTheme; 1939 &TestingAutomationProvider::ResetToDefaultTheme;
1944 1940
1945 // SetTheme() implemented using InstallExtension(). 1941 // SetTheme() implemented using InstallExtension().
1946 browser_handler_map_["GetThemeInfo"] = 1942 browser_handler_map_["GetThemeInfo"] =
1947 &TestingAutomationProvider::GetThemeInfo; 1943 &TestingAutomationProvider::GetThemeInfo;
1948 1944
1949 browser_handler_map_["FindInPage"] = &TestingAutomationProvider::FindInPage; 1945 browser_handler_map_["FindInPage"] = &TestingAutomationProvider::FindInPage;
1950 1946
1951 browser_handler_map_["SelectTranslateOption"] = 1947 browser_handler_map_["SelectTranslateOption"] =
(...skipping 1987 matching lines...) Expand 10 before | Expand all | Expand 10 after
3939 // This is the function called when an infobar is dismissed or when the 3935 // This is the function called when an infobar is dismissed or when the
3940 // user clicks the 'Nope' translate button. 3936 // user clicks the 'Nope' translate button.
3941 translate_bar->TranslationDeclined(); 3937 translate_bar->TranslationDeclined();
3942 tab_contents->infobar_tab_helper()->RemoveInfoBar(translate_bar); 3938 tab_contents->infobar_tab_helper()->RemoveInfoBar(translate_bar);
3943 reply.SendSuccess(NULL); 3939 reply.SendSuccess(NULL);
3944 } else { 3940 } else {
3945 reply.SendError("Invalid string found for option."); 3941 reply.SendError("Invalid string found for option.");
3946 } 3942 }
3947 } 3943 }
3948 3944
3949 // Sample json input: { "command": "GetBlockedPopupsInfo",
3950 // "tab_index": 1 }
3951 // Refer GetBlockedPopupsInfo() in pyauto.py for sample output.
3952 void TestingAutomationProvider::GetBlockedPopupsInfo(
3953 Browser* browser,
3954 DictionaryValue* args,
3955 IPC::Message* reply_message) {
3956 AutomationJSONReply reply(this, reply_message);
3957 std::string error_message;
3958 TabContents* tab_contents = GetTabContentsFromDict(
3959 browser, args, &error_message);
3960 if (!tab_contents) {
3961 reply.SendError(error_message);
3962 return;
3963 }
3964 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
3965 BlockedContentTabHelper* blocked_content =
3966 tab_contents->blocked_content_tab_helper();
3967 ListValue* blocked_popups_list = new ListValue;
3968 std::vector<TabContents*> blocked_contents;
3969 blocked_content->GetBlockedContents(&blocked_contents);
3970 for (std::vector<TabContents*>::const_iterator it =
3971 blocked_contents.begin(); it != blocked_contents.end(); ++it) {
3972 DictionaryValue* item = new DictionaryValue;
3973 item->SetString("url", (*it)->web_contents()->GetURL().spec());
3974 item->SetString("title", (*it)->web_contents()->GetTitle());
3975 blocked_popups_list->Append(item);
3976 }
3977 return_value->Set("blocked_popups", blocked_popups_list);
3978 reply.SendSuccess(return_value.get());
3979 }
3980
3981 // Refer UnblockAndLaunchBlockedPopup() in pyauto.py for sample input.
3982 void TestingAutomationProvider::UnblockAndLaunchBlockedPopup(
3983 Browser* browser,
3984 DictionaryValue* args,
3985 IPC::Message* reply_message) {
3986 AutomationJSONReply reply(this, reply_message);
3987 std::string error_message;
3988 TabContents* tab_contents = GetTabContentsFromDict(
3989 browser, args, &error_message);
3990 if (!tab_contents) {
3991 reply.SendError(error_message);
3992 return;
3993 }
3994 int popup_index;
3995 if (!args->GetInteger("popup_index", &popup_index)) {
3996 reply.SendError("Need popup_index arg");
3997 return;
3998 }
3999 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
4000 BlockedContentTabHelper* blocked_content =
4001 tab_contents->blocked_content_tab_helper();
4002 if (popup_index >= (int)blocked_content->GetBlockedContentsCount()) {
4003 reply.SendError(StringPrintf("No popup at index %d", popup_index));
4004 return;
4005 }
4006 std::vector<TabContents*> blocked_contents;
4007 blocked_content->GetBlockedContents(&blocked_contents);
4008 blocked_content->LaunchForContents(blocked_contents[popup_index]);
4009 reply.SendSuccess(NULL);
4010 }
4011
4012 // Sample json input: { "command": "GetThemeInfo" } 3945 // Sample json input: { "command": "GetThemeInfo" }
4013 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output. 3946 // Refer GetThemeInfo() in chrome/test/pyautolib/pyauto.py for sample output.
4014 void TestingAutomationProvider::GetThemeInfo( 3947 void TestingAutomationProvider::GetThemeInfo(
4015 Browser* browser, 3948 Browser* browser,
4016 DictionaryValue* args, 3949 DictionaryValue* args,
4017 IPC::Message* reply_message) { 3950 IPC::Message* reply_message) {
4018 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 3951 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
4019 const Extension* theme = ThemeServiceFactory::GetThemeForProfile(profile()); 3952 const Extension* theme = ThemeServiceFactory::GetThemeForProfile(profile());
4020 if (theme) { 3953 if (theme) {
4021 return_value->SetString("name", theme->name()); 3954 return_value->SetString("name", theme->name());
(...skipping 2714 matching lines...) Expand 10 before | Expand all | Expand 10 after
6736 void TestingAutomationProvider::OnRemoveProvider() { 6669 void TestingAutomationProvider::OnRemoveProvider() {
6737 if (g_browser_process) 6670 if (g_browser_process)
6738 g_browser_process->GetAutomationProviderList()->RemoveProvider(this); 6671 g_browser_process->GetAutomationProviderList()->RemoveProvider(this);
6739 } 6672 }
6740 6673
6741 void TestingAutomationProvider::EnsureTabSelected(Browser* browser, 6674 void TestingAutomationProvider::EnsureTabSelected(Browser* browser,
6742 WebContents* tab) { 6675 WebContents* tab) {
6743 if (chrome::GetActiveWebContents(browser) != tab) 6676 if (chrome::GetActiveWebContents(browser) != tab)
6744 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true); 6677 chrome::ActivateTabAt(browser, chrome::GetIndexOfTab(browser, tab), true);
6745 } 6678 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/browser/policy/policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698