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

Side by Side Diff: components/autofill/core/browser/autofill_external_delegate_unittest.cc

Issue 69293007: Abstracted AutofillMsg_SetNodeText IPC out of core autofill code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment. Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <vector> 5 #include <vector>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
(...skipping 28 matching lines...) Expand all
39 explicit MockAutofillDriver(content::WebContents* web_contents) 39 explicit MockAutofillDriver(content::WebContents* web_contents)
40 : TestAutofillDriver(web_contents) {} 40 : TestAutofillDriver(web_contents) {}
41 41
42 // Mock methods to enable testability. 42 // Mock methods to enable testability.
43 MOCK_METHOD1(SetRendererActionOnFormDataReception, 43 MOCK_METHOD1(SetRendererActionOnFormDataReception,
44 void(RendererFormDataAction action)); 44 void(RendererFormDataAction action));
45 MOCK_METHOD1(RendererShouldAcceptDataListSuggestion, 45 MOCK_METHOD1(RendererShouldAcceptDataListSuggestion,
46 void(const base::string16&)); 46 void(const base::string16&));
47 MOCK_METHOD0(RendererShouldClearFilledForm, void()); 47 MOCK_METHOD0(RendererShouldClearFilledForm, void());
48 MOCK_METHOD0(RendererShouldClearPreviewedForm, void()); 48 MOCK_METHOD0(RendererShouldClearPreviewedForm, void());
49 MOCK_METHOD1(RendererShouldSetNodeText, void(const base::string16&));
49 50
50 private: 51 private:
51 DISALLOW_COPY_AND_ASSIGN(MockAutofillDriver); 52 DISALLOW_COPY_AND_ASSIGN(MockAutofillDriver);
52 }; 53 };
53 54
54 class MockAutofillManagerDelegate 55 class MockAutofillManagerDelegate
55 : public autofill::TestAutofillManagerDelegate { 56 : public autofill::TestAutofillManagerDelegate {
56 public: 57 public:
57 MockAutofillManagerDelegate() {} 58 MockAutofillManagerDelegate() {}
58 59
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // we've selected an option. 433 // we've selected an option.
433 external_delegate_->DidAcceptSuggestion( 434 external_delegate_->DidAcceptSuggestion(
434 suggestions[0], 435 suggestions[0],
435 WebAutofillClient::MenuItemIDPasswordEntry); 436 WebAutofillClient::MenuItemIDPasswordEntry);
436 } 437 }
437 438
438 // Test that the driver is directed to accept the data list after being notified 439 // Test that the driver is directed to accept the data list after being notified
439 // that the user accepted the data list suggestion. 440 // that the user accepted the data list suggestion.
440 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) { 441 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateAcceptSuggestion) {
441 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); 442 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
442 base::string16 dummyString(ASCIIToUTF16("baz qux")); 443 base::string16 dummy_string(ASCIIToUTF16("baz qux"));
443 EXPECT_CALL(*autofill_driver_, 444 EXPECT_CALL(*autofill_driver_,
444 RendererShouldAcceptDataListSuggestion(dummyString)); 445 RendererShouldAcceptDataListSuggestion(dummy_string));
445 external_delegate_->DidAcceptSuggestion( 446 external_delegate_->DidAcceptSuggestion(
446 dummyString, 447 dummy_string,
447 WebAutofillClient::MenuItemIDDataListEntry); 448 WebAutofillClient::MenuItemIDDataListEntry);
448 } 449 }
449 450
450 // Test that the driver is directed to clear the form after being notified that 451 // Test that the driver is directed to clear the form after being notified that
451 // the user accepted the suggestion to clear the form. 452 // the user accepted the suggestion to clear the form.
452 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearForm) { 453 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateClearForm) {
453 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); 454 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
454 EXPECT_CALL(*autofill_driver_, RendererShouldClearFilledForm()); 455 EXPECT_CALL(*autofill_driver_, RendererShouldClearFilledForm());
455 456
456 external_delegate_->DidAcceptSuggestion( 457 external_delegate_->DidAcceptSuggestion(
(...skipping 20 matching lines...) Expand all
477 // anything. 478 // anything.
478 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); 479 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
479 480
480 external_delegate_->OnSuggestionsReturned(kQueryId, 481 external_delegate_->OnSuggestionsReturned(kQueryId,
481 autofill_items, 482 autofill_items,
482 autofill_items, 483 autofill_items,
483 autofill_items, 484 autofill_items,
484 autofill_ids); 485 autofill_ids);
485 } 486 }
486 487
488 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateSetNodeText) {
489 EXPECT_CALL(manager_delegate_, HideAutofillPopup());
490 base::string16 dummy_string(ASCIIToUTF16("baz foo"));
491 EXPECT_CALL(*autofill_driver_,
492 RendererShouldSetNodeText(dummy_string));
493 external_delegate_->DidAcceptSuggestion(
494 dummy_string,
495 WebAutofillClient::MenuItemIDAutocompleteEntry);
496 }
497
487 } // namespace autofill 498 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698