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

Side by Side Diff: chrome/browser/autofill/autofill_external_delegate_unittest.cc

Issue 11000016: Move forms/ out of webkit/. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Mostly cosmetic fixup Created 8 years, 2 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
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 <vector> 5 #include <vector>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/autofill/autofill_manager.h" 10 #include "chrome/browser/autofill/autofill_manager.h"
11 #include "chrome/browser/autofill/test_autofill_external_delegate.h" 11 #include "chrome/browser/autofill/test_autofill_external_delegate.h"
12 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" 12 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h"
13 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" 13 #include "chrome/browser/ui/tab_contents/test_tab_contents.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "content/public/common/form_data.h"
16 #include "content/public/common/form_field.h"
15 #include "content/public/test/test_browser_thread.h" 17 #include "content/public/test/test_browser_thread.h"
16 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h"
19 #include "ui/gfx/rect.h" 21 #include "ui/gfx/rect.h"
20 #include "webkit/forms/form_data.h"
21 #include "webkit/forms/form_field.h"
22 22
23 using content::BrowserThread; 23 using content::BrowserThread;
24 using content::FormData;
25 using content::FormField;
24 using testing::_; 26 using testing::_;
25 using webkit::forms::FormData;
26 using webkit::forms::FormField;
27 using WebKit::WebAutofillClient; 27 using WebKit::WebAutofillClient;
28 28
29 namespace { 29 namespace {
30 30
31 // A constant value to use as the Autofill query ID. 31 // A constant value to use as the Autofill query ID.
32 const int kQueryId = 5; 32 const int kQueryId = 5;
33 33
34 // A constant value to use as an Autofill profile ID. 34 // A constant value to use as an Autofill profile ID.
35 const int kAutofillProfileId = 1; 35 const int kAutofillProfileId = 1;
36 36
37 class MockAutofillExternalDelegate : public TestAutofillExternalDelegate { 37 class MockAutofillExternalDelegate : public TestAutofillExternalDelegate {
38 public: 38 public:
39 MockAutofillExternalDelegate(TabContents* tab_contents, 39 MockAutofillExternalDelegate(TabContents* tab_contents,
40 AutofillManager* autofill_manger) 40 AutofillManager* autofill_manger)
41 : TestAutofillExternalDelegate(tab_contents, autofill_manger) {} 41 : TestAutofillExternalDelegate(tab_contents, autofill_manger) {}
42 ~MockAutofillExternalDelegate() {} 42 ~MockAutofillExternalDelegate() {}
43 43
44 MOCK_METHOD4(ApplyAutofillSuggestions, void( 44 MOCK_METHOD4(ApplyAutofillSuggestions, void(
45 const std::vector<string16>& autofill_values, 45 const std::vector<string16>& autofill_values,
46 const std::vector<string16>& autofill_labels, 46 const std::vector<string16>& autofill_labels,
47 const std::vector<string16>& autofill_icons, 47 const std::vector<string16>& autofill_icons,
48 const std::vector<int>& autofill_unique_ids)); 48 const std::vector<int>& autofill_unique_ids));
49 49
50 MOCK_METHOD4(OnQueryPlatformSpecific, 50 MOCK_METHOD4(OnQueryPlatformSpecific,
51 void(int query_id, 51 void(int query_id,
52 const webkit::forms::FormData& form, 52 const content::FormData& form,
53 const webkit::forms::FormField& field, 53 const content::FormField& field,
54 const gfx::Rect& bounds)); 54 const gfx::Rect& bounds));
55 55
56 MOCK_METHOD0(ClearPreviewedForm, void()); 56 MOCK_METHOD0(ClearPreviewedForm, void());
57 57
58 MOCK_METHOD0(HideAutofillPopup, void()); 58 MOCK_METHOD0(HideAutofillPopup, void());
59 59
60 private: 60 private:
61 virtual void HideAutofillPopupInternal() {}; 61 virtual void HideAutofillPopupInternal() {};
62 }; 62 };
63 63
64 class MockAutofillManager : public AutofillManager { 64 class MockAutofillManager : public AutofillManager {
65 public: 65 public:
66 explicit MockAutofillManager(autofill::AutofillManagerDelegate* delegate, 66 explicit MockAutofillManager(autofill::AutofillManagerDelegate* delegate,
67 TabContents* tab_contents) 67 TabContents* tab_contents)
68 // Force to use the constructor designated for unit test, but we don't 68 // Force to use the constructor designated for unit test, but we don't
69 // really need personal_data in this test so we pass a NULL pointer. 69 // really need personal_data in this test so we pass a NULL pointer.
70 : AutofillManager(delegate, tab_contents, NULL) { 70 : AutofillManager(delegate, tab_contents, NULL) {
71 } 71 }
72 72
73 MOCK_METHOD4(OnFillAutofillFormData, 73 MOCK_METHOD4(OnFillAutofillFormData,
74 void(int query_id, 74 void(int query_id,
75 const webkit::forms::FormData& form, 75 const content::FormData& form,
76 const webkit::forms::FormField& field, 76 const content::FormField& field,
77 int unique_id)); 77 int unique_id));
78 78
79 protected: 79 protected:
80 virtual ~MockAutofillManager() {} 80 virtual ~MockAutofillManager() {}
81 }; 81 };
82 82
83 } // namespace 83 } // namespace
84 84
85 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness { 85 class AutofillExternalDelegateUnitTest : public TabContentsTestHarness {
86 public: 86 public:
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 external_delegate_->SelectAutofillSuggestionAtIndex(1); 245 external_delegate_->SelectAutofillSuggestionAtIndex(1);
246 } 246 }
247 247
248 // Test that the popup is hidden once we are done editing the autofill field. 248 // Test that the popup is hidden once we are done editing the autofill field.
249 TEST_F(AutofillExternalDelegateUnitTest, 249 TEST_F(AutofillExternalDelegateUnitTest,
250 ExternalDelegateHidePopupAfterEditing) { 250 ExternalDelegateHidePopupAfterEditing) {
251 EXPECT_CALL(*external_delegate_, HideAutofillPopup()); 251 EXPECT_CALL(*external_delegate_, HideAutofillPopup());
252 252
253 external_delegate_->DidEndTextFieldEditing(); 253 external_delegate_->DidEndTextFieldEditing();
254 } 254 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698