Commit e5f069d5 authored by pritam.nikam's avatar pritam.nikam Committed by Commit bot

[Password Manager] Unfriend PasswordAutofillAgentTest from PasswordAutofillAgent (clean-up).

BUG=368160
TBR=phajdan.jr@chromium.org

Review URL: https://codereview.chromium.org/563313004

Cr-Commit-Position: refs/heads/master@{#296071}
parent 07528460
...@@ -54,6 +54,14 @@ class AutofillRendererTest : public ChromeRenderViewTest { ...@@ -54,6 +54,14 @@ class AutofillRendererTest : public ChromeRenderViewTest {
SendContentStateImmediately(); SendContentStateImmediately();
} }
void SimulateRequestAutocompleteResult(
const blink::WebFormElement::AutocompleteResult& result,
const base::string16& message) {
AutofillMsg_RequestAutocompleteResult msg(0, result, message, FormData());
static_cast<content::RenderViewObserver*>(autofill_agent_)
->OnMessageReceived(msg);
}
private: private:
DISALLOW_COPY_AND_ASSIGN(AutofillRendererTest); DISALLOW_COPY_AND_ASSIGN(AutofillRendererTest);
}; };
...@@ -199,7 +207,8 @@ TEST_F(AutofillRendererTest, ShowAutofillWarning) { ...@@ -199,7 +207,8 @@ TEST_F(AutofillRendererTest, ShowAutofillWarning) {
// Simulate attempting to Autofill the form from the first element, which // Simulate attempting to Autofill the form from the first element, which
// specifies autocomplete="off". This should still trigger an IPC which // specifies autocomplete="off". This should still trigger an IPC which
// shouldn't display warnings. // shouldn't display warnings.
autofill_agent_->FormControlElementClicked(firstname, true); static_cast<PageClickListener*>(autofill_agent_)
->FormControlElementClicked(firstname, true);
const IPC::Message* message1 = render_thread_->sink().GetFirstMessageMatching( const IPC::Message* message1 = render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_QueryFormFieldAutofill::ID); AutofillHostMsg_QueryFormFieldAutofill::ID);
EXPECT_NE(static_cast<IPC::Message*>(NULL), message1); EXPECT_NE(static_cast<IPC::Message*>(NULL), message1);
...@@ -213,7 +222,8 @@ TEST_F(AutofillRendererTest, ShowAutofillWarning) { ...@@ -213,7 +222,8 @@ TEST_F(AutofillRendererTest, ShowAutofillWarning) {
// does not specify autocomplete="off". This should trigger an IPC that will // does not specify autocomplete="off". This should trigger an IPC that will
// show warnings, as we *do* show warnings for elements that don't themselves // show warnings, as we *do* show warnings for elements that don't themselves
// set autocomplete="off", but for which the form does. // set autocomplete="off", but for which the form does.
autofill_agent_->FormControlElementClicked(middlename, true); static_cast<PageClickListener*>(autofill_agent_)
->FormControlElementClicked(middlename, true);
const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching( const IPC::Message* message2 = render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_QueryFormFieldAutofill::ID); AutofillHostMsg_QueryFormFieldAutofill::ID);
ASSERT_NE(static_cast<IPC::Message*>(NULL), message2); ASSERT_NE(static_cast<IPC::Message*>(NULL), message2);
...@@ -277,7 +287,8 @@ class RequestAutocompleteRendererTest : public AutofillRendererTest { ...@@ -277,7 +287,8 @@ class RequestAutocompleteRendererTest : public AutofillRendererTest {
render_thread_->sink().ClearMessages(); render_thread_->sink().ClearMessages();
// Invoke requestAutocomplete to show the dialog. // Invoke requestAutocomplete to show the dialog.
autofill_agent_->didRequestAutocomplete(invoking_form()); static_cast<blink::WebAutofillClient*>(autofill_agent_)
->didRequestAutocomplete(invoking_form());
ASSERT_TRUE(render_thread_->sink().GetFirstMessageMatching( ASSERT_TRUE(render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_RequestAutocomplete::ID)); AutofillHostMsg_RequestAutocomplete::ID));
...@@ -329,10 +340,9 @@ TEST_F(RequestAutocompleteRendererTest, MainFrameNavigateCancels) { ...@@ -329,10 +340,9 @@ TEST_F(RequestAutocompleteRendererTest, MainFrameNavigateCancels) {
TEST_F(RequestAutocompleteRendererTest, NoCancelOnSubframeNavigateAfterDone) { TEST_F(RequestAutocompleteRendererTest, NoCancelOnSubframeNavigateAfterDone) {
// Pretend that the dialog was cancelled. // Pretend that the dialog was cancelled.
autofill_agent_->OnRequestAutocompleteResult( SimulateRequestAutocompleteResult(
WebFormElement::AutocompleteResultErrorCancel, WebFormElement::AutocompleteResultErrorCancel,
base::ASCIIToUTF16("Print me to the console"), base::ASCIIToUTF16("Print me to the console"));
FormData());
// Additional navigations should not crash nor send cancels. // Additional navigations should not crash nor send cancels.
NavigateFrame(invoking_frame()); NavigateFrame(invoking_frame());
...@@ -342,10 +352,9 @@ TEST_F(RequestAutocompleteRendererTest, NoCancelOnSubframeNavigateAfterDone) { ...@@ -342,10 +352,9 @@ TEST_F(RequestAutocompleteRendererTest, NoCancelOnSubframeNavigateAfterDone) {
TEST_F(RequestAutocompleteRendererTest, NoCancelOnMainFrameNavigateAfterDone) { TEST_F(RequestAutocompleteRendererTest, NoCancelOnMainFrameNavigateAfterDone) {
// Pretend that the dialog was cancelled. // Pretend that the dialog was cancelled.
autofill_agent_->OnRequestAutocompleteResult( SimulateRequestAutocompleteResult(
WebFormElement::AutocompleteResultErrorCancel, WebFormElement::AutocompleteResultErrorCancel,
base::ASCIIToUTF16("Print me to the console"), base::ASCIIToUTF16("Print me to the console"));
FormData());
// Additional navigations should not crash nor send cancels. // Additional navigations should not crash nor send cancels.
NavigateFrame(GetMainFrame()); NavigateFrame(GetMainFrame());
...@@ -355,7 +364,8 @@ TEST_F(RequestAutocompleteRendererTest, NoCancelOnMainFrameNavigateAfterDone) { ...@@ -355,7 +364,8 @@ TEST_F(RequestAutocompleteRendererTest, NoCancelOnMainFrameNavigateAfterDone) {
TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) { TEST_F(RequestAutocompleteRendererTest, InvokingTwiceOnlyShowsOnce) {
// Attempting to show the requestAutocomplete dialog again should be ignored. // Attempting to show the requestAutocomplete dialog again should be ignored.
autofill_agent_->didRequestAutocomplete(invoking_form()); static_cast<blink::WebAutofillClient*>(autofill_agent_)
->didRequestAutocomplete(invoking_form());
EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
AutofillHostMsg_RequestAutocomplete::ID)); AutofillHostMsg_RequestAutocomplete::ID));
} }
......
...@@ -46,7 +46,7 @@ using blink::WebString; ...@@ -46,7 +46,7 @@ using blink::WebString;
using blink::WebURLRequest; using blink::WebURLRequest;
ChromeRenderViewTest::ChromeRenderViewTest() ChromeRenderViewTest::ChromeRenderViewTest()
: password_autofill_(NULL), : password_autofill_agent_(NULL),
password_generation_(NULL), password_generation_(NULL),
autofill_agent_(NULL), autofill_agent_(NULL),
chrome_render_thread_(NULL) { chrome_render_thread_(NULL) {
...@@ -67,10 +67,10 @@ void ChromeRenderViewTest::SetUp() { ...@@ -67,10 +67,10 @@ void ChromeRenderViewTest::SetUp() {
// RenderView doesn't expose its Agent objects, because it has no need to // RenderView doesn't expose its Agent objects, because it has no need to
// store them directly (they're stored as RenderViewObserver*). So just // store them directly (they're stored as RenderViewObserver*). So just
// create another set. // create another set.
password_autofill_ = new autofill::TestPasswordAutofillAgent(view_); password_autofill_agent_ = new autofill::TestPasswordAutofillAgent(view_);
password_generation_ = new autofill::TestPasswordGenerationAgent(view_); password_generation_ = new autofill::TestPasswordGenerationAgent(view_);
autofill_agent_ = autofill_agent_ =
new AutofillAgent(view_, password_autofill_, password_generation_); new AutofillAgent(view_, password_autofill_agent_, password_generation_);
} }
void ChromeRenderViewTest::TearDown() { void ChromeRenderViewTest::TearDown() {
......
...@@ -39,7 +39,7 @@ class ChromeRenderViewTest : public content::RenderViewTest { ...@@ -39,7 +39,7 @@ class ChromeRenderViewTest : public content::RenderViewTest {
scoped_ptr<extensions::DispatcherDelegate> extension_dispatcher_delegate_; scoped_ptr<extensions::DispatcherDelegate> extension_dispatcher_delegate_;
#endif #endif
autofill::TestPasswordAutofillAgent* password_autofill_; autofill::TestPasswordAutofillAgent* password_autofill_agent_;
autofill::TestPasswordGenerationAgent* password_generation_; autofill::TestPasswordGenerationAgent* password_generation_;
autofill::AutofillAgent* autofill_agent_; autofill::AutofillAgent* autofill_agent_;
......
...@@ -230,25 +230,6 @@ class AutofillAgent : public content::RenderViewObserver, ...@@ -230,25 +230,6 @@ class AutofillAgent : public content::RenderViewObserver,
base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_;
friend class PasswordAutofillAgentTest;
friend class RequestAutocompleteRendererTest;
FRIEND_TEST_ALL_PREFIXES(AutofillRendererTest, FillFormElement);
FRIEND_TEST_ALL_PREFIXES(AutofillRendererTest, SendDynamicForms);
FRIEND_TEST_ALL_PREFIXES(AutofillRendererTest, ShowAutofillWarning);
FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, WaitUsername);
FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, SuggestionAccept);
FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, SuggestionSelect);
FRIEND_TEST_ALL_PREFIXES(
PasswordAutofillAgentTest,
PasswordAutofillTriggersOnChangeEventsWaitForUsername);
FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, CredentialsOnClick);
FRIEND_TEST_ALL_PREFIXES(RequestAutocompleteRendererTest,
NoCancelOnMainFrameNavigateAfterDone);
FRIEND_TEST_ALL_PREFIXES(RequestAutocompleteRendererTest,
NoCancelOnSubframeNavigateAfterDone);
FRIEND_TEST_ALL_PREFIXES(RequestAutocompleteRendererTest,
InvokingTwiceOnlyShowsOnce);
DISALLOW_COPY_AND_ASSIGN(AutofillAgent); DISALLOW_COPY_AND_ASSIGN(AutofillAgent);
}; };
......
...@@ -73,8 +73,6 @@ class PasswordAutofillAgent : public content::RenderViewObserver { ...@@ -73,8 +73,6 @@ class PasswordAutofillAgent : public content::RenderViewObserver {
const blink::WebSecurityOrigin& origin); const blink::WebSecurityOrigin& origin);
private: private:
friend class PasswordAutofillAgentTest;
enum OtherPossibleUsernamesUsage { enum OtherPossibleUsernamesUsage {
NOTHING_TO_AUTOFILL, NOTHING_TO_AUTOFILL,
OTHER_POSSIBLE_USERNAMES_ABSENT, OTHER_POSSIBLE_USERNAMES_ABSENT,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment