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

Unified Diff: components/autofill/content/browser/content_autofill_driver_unittest.cc

Issue 2603583002: Add user-gesture-related tests for ContentAutofillDriver (Closed)
Patch Set: Simpler test Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/content/browser/content_autofill_driver_unittest.cc
diff --git a/components/autofill/content/browser/content_autofill_driver_unittest.cc b/components/autofill/content/browser/content_autofill_driver_unittest.cc
index 82dd2f6254a902f05767ce706bf9f83f43a0f7a7..3dbbd572f3c684364d9d1b4862b645c751bd3109 100644
--- a/components/autofill/content/browser/content_autofill_driver_unittest.cc
+++ b/components/autofill/content/browser/content_autofill_driver_unittest.cc
@@ -137,6 +137,9 @@ class FakeAutofillAgent : public mojom::AutofillAgent {
return true;
}
+ // Mocked mojom::AutofillAgent methods:
+ MOCK_METHOD0(FirstUserGestureObservedInTab, void());
+
private:
void CallDone() {
if (!quit_closure_.is_null()) {
@@ -145,9 +148,7 @@ class FakeAutofillAgent : public mojom::AutofillAgent {
}
}
- // mojom::AutofillAgent methods:
- void FirstUserGestureObservedInTab() override {}
-
+ // mojom::AutofillAgent:
void FillForm(int32_t id, const FormData& form) override {
fill_form_id_ = id;
fill_form_form_ = form;
@@ -236,6 +237,11 @@ class MockAutofillManager : public AutofillManager {
MOCK_METHOD0(Reset, void());
};
+class MockAutofillClient : public TestAutofillClient {
+ public:
+ MOCK_METHOD0(OnFirstUserGestureObserved, void());
+};
+
class TestContentAutofillDriver : public ContentAutofillDriver {
public:
TestContentAutofillDriver(content::RenderFrameHost* rfh,
@@ -259,7 +265,7 @@ class ContentAutofillDriverTest : public content::RenderViewHostTestHarness {
void SetUp() override {
content::RenderViewHostTestHarness::SetUp();
- test_autofill_client_.reset(new TestAutofillClient());
+ test_autofill_client_.reset(new MockAutofillClient());
driver_.reset(new TestContentAutofillDriver(web_contents()->GetMainFrame(),
test_autofill_client_.get()));
@@ -279,7 +285,7 @@ class ContentAutofillDriverTest : public content::RenderViewHostTestHarness {
}
protected:
- std::unique_ptr<TestAutofillClient> test_autofill_client_;
+ std::unique_ptr<MockAutofillClient> test_autofill_client_;
std::unique_ptr<TestContentAutofillDriver> driver_;
FakeAutofillAgent fake_agent_;
@@ -479,4 +485,15 @@ TEST_F(ContentAutofillDriverTest, CreditCardFormInteractionOnHTTPS) {
content::SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP));
}
+TEST_F(ContentAutofillDriverTest, NotifyFirstUserGestureObservedInTab) {
+ driver_->NotifyFirstUserGestureObservedInTab();
+ EXPECT_CALL(fake_agent_, FirstUserGestureObservedInTab());
+ base::RunLoop().RunUntilIdle();
+}
+
+TEST_F(ContentAutofillDriverTest, FirstUserGestureObserved) {
+ EXPECT_CALL(*test_autofill_client_, OnFirstUserGestureObserved());
+ driver_->FirstUserGestureObserved();
+}
+
} // namespace autofill
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698