Skip to content

Commit

Permalink
[rAC, OSX] Enabled autocomplete event browser tests.
Browse files Browse the repository at this point in the history
Enable browsertests that rely on autocomplete events in HTML.

R=isherman@chromium.org
BUG=256864

Review URL: https://chromiumcodereview.appspot.com/19800006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214566 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
groby@chromium.org committed Jul 31, 2013
1 parent 0d0ed64 commit e9792e2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ class AutofillDialogControllerTest : public InProcessBrowserTest {
AutofillDialogControllerTest() {}
virtual ~AutofillDialogControllerTest() {}

virtual void SetUpOnMainThread() OVERRIDE {
autofill::test::DisableSystemServices(browser()->profile());
}

virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
#if defined(OS_MACOSX)
// OSX support for requestAutocomplete is still hidden behind a switch.
// Pending resolution of http://crbug.com/157274
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableInteractiveAutocomplete);
#endif
}

void InitializeControllerOfType(DialogType dialog_type) {
FormData form;
form.name = ASCIIToUTF16("TestForm");
Expand Down Expand Up @@ -702,14 +715,7 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, LongNotifications) {
controller()->GetTestableView()->GetSize().width());
}

#if defined(OS_MACOSX)
// TODO(groby): Implement the necessary functionality and enable this test:
// http://crbug.com/256864
#define MAYBE_AutocompleteEvent DISABLED_AutocompleteEvent
#else
#define MAYBE_AutocompleteEvent AutocompleteEvent
#endif
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_AutocompleteEvent) {
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, AutocompleteEvent) {
AutofillDialogControllerImpl* controller =
SetUpHtmlAndInvoke("<input autocomplete='cc-name'>");

Expand All @@ -723,17 +729,8 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest, MAYBE_AutocompleteEvent) {
ExpectDomMessage("success");
}

#if defined(OS_MACOSX)
// TODO(groby): Implement the necessary functionality and enable this test:
// http://crbug.com/256864
#define MAYBE_AutocompleteErrorEventReasonInvalid \
DISABLED_AutocompleteErrorEventReasonInvalid
#else
#define MAYBE_AutocompleteErrorEventReasonInvalid \
AutocompleteErrorEventReasonInvalid
#endif
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
MAYBE_AutocompleteErrorEventReasonInvalid) {
AutocompleteErrorEventReasonInvalid) {
AutofillDialogControllerImpl* controller =
SetUpHtmlAndInvoke("<input autocomplete='cc-name' pattern='.*zebra.*'>");

Expand All @@ -751,17 +748,8 @@ IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
ExpectDomMessage("error: invalid");
}

#if defined(OS_MACOSX)
// TODO(groby): Implement the necessary functionality and enable this test:
// http://crbug.com/256864
#define MAYBE_AutocompleteErrorEventReasonCancel \
DISABLED_AutocompleteErrorEventReasonCancel
#else
#define MAYBE_AutocompleteErrorEventReasonCancel \
AutocompleteErrorEventReasonCancel
#endif
IN_PROC_BROWSER_TEST_F(AutofillDialogControllerTest,
MAYBE_AutocompleteErrorEventReasonCancel) {
AutocompleteErrorEventReasonCancel) {
SetUpHtmlAndInvoke("<input autocomplete='cc-name'>")->GetTestableView()->
CancelForTesting();
ExpectDomMessage("error: cancel");
Expand Down
4 changes: 4 additions & 0 deletions chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ class AutofillDialogCocoa : public AutofillDialogView,

// Mirrors the TestableAutofillDialogView API on the C++ side.
@interface AutofillDialogWindowController (TestableAutofillDialogView)

- (void)setTextContents:(NSString*)text
forInput:(const autofill::DetailInput&)input;
- (void)setTextContents:(NSString*)text
ofSuggestionForSection:(autofill::DialogSection)section;
- (void)activateFieldForInput:(const autofill::DetailInput&)input;

@end

#endif // CHROME_BROWSER_UI_COCOA_AUTOFILL_AUTOFILL_DIALOG_COCOA_H_
8 changes: 7 additions & 1 deletion chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@
void AutofillDialogCocoa::SetTextContentsOfSuggestionInput(
DialogSection section,
const base::string16& text) {
// TODO(groby): Implement Mac support for this: http://crbug.com/256864
[sheet_controller_ setTextContents:base::SysUTF16ToNSString(text)
ofSuggestionForSection:section];
}

void AutofillDialogCocoa::ActivateInput(const DetailInput& input) {
Expand Down Expand Up @@ -405,6 +406,11 @@ - (void)setTextContents:(NSString*)text
}
}

- (void)setTextContents:(NSString*)text
ofSuggestionForSection:(autofill::DialogSection)section {
[[mainContainer_ sectionForId:section] setSuggestionFieldValue:text];
}

- (void)activateFieldForInput:(const autofill::DetailInput&)input {
for (size_t i = autofill::SECTION_MIN; i <= autofill::SECTION_MAX; ++i) {
autofill::DialogSection section = static_cast<autofill::DialogSection>(i);
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/ui/cocoa/autofill/autofill_section_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ namespace autofill {
- (void)setFieldValue:(NSString*)text
forInput:(const autofill::DetailInput&)input;

// Sets the value for the suggestion text field.
- (void)setSuggestionFieldValue:(NSString*)text;

// Activates a given input field, determined by |input|. Does nothing if the
// field is not part of this section.
- (void)activateFieldForInput:(const autofill::DetailInput&)input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,10 @@ - (void)setFieldValue:(NSString*)text
[field setFieldValue:text];
}

- (void)setSuggestionFieldValue:(NSString*)text {
[[suggestContainer_ inputField] setFieldValue:text];
}

- (void)activateFieldForInput:(const autofill::DetailInput&)input {
if ([self detailInputForType:input.type] != &input)
return;
Expand Down

0 comments on commit e9792e2

Please sign in to comment.