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

Unified Diff: components/password_manager/content/browser/content_password_manager_driver_unittest.cc

Issue 2274783002: Revert of [Autofill] Migrate ContentPasswordManagerDriver<-->Password{Autofill,Generation}Agent IPCs to mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/content/browser/content_password_manager_driver_unittest.cc
diff --git a/components/password_manager/content/browser/content_password_manager_driver_unittest.cc b/components/password_manager/content/browser/content_password_manager_driver_unittest.cc
index 06e21b397ded4a8bfb76854026bbb627bbb84071..267aa3797ac7348c166682252865e2c2bc97265f 100644
--- a/components/password_manager/content/browser/content_password_manager_driver_unittest.cc
+++ b/components/password_manager/content/browser/content_password_manager_driver_unittest.cc
@@ -4,16 +4,17 @@
#include "components/password_manager/content/browser/content_password_manager_driver.h"
+#include <stdint.h>
+
+#include <tuple>
+
#include "base/macros.h"
-#include "base/run_loop.h"
-#include "components/autofill/content/public/interfaces/autofill_agent.mojom.h"
+#include "components/autofill/content/common/autofill_messages.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/password_manager/core/browser/stub_log_manager.h"
#include "components/password_manager/core/browser/stub_password_manager_client.h"
-#include "content/public/browser/web_contents.h"
+#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_renderer_host.h"
-#include "mojo/public/cpp/bindings/binding.h"
-#include "services/shell/public/cpp/interface_provider.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -39,55 +40,6 @@
DISALLOW_COPY_AND_ASSIGN(MockPasswordManagerClient);
};
-class FakePasswordAutofillAgent
- : public autofill::mojom::PasswordAutofillAgent {
- public:
- FakePasswordAutofillAgent()
- : called_set_logging_state_(false),
- logging_state_active_(false),
- binding_(this) {}
-
- ~FakePasswordAutofillAgent() override {}
-
- void BindRequest(mojo::ScopedMessagePipeHandle handle) {
- binding_.Bind(mojo::MakeRequest<autofill::mojom::PasswordAutofillAgent>(
- std::move(handle)));
- }
-
- bool called_set_logging_state() { return called_set_logging_state_; }
-
- bool logging_state_active() { return logging_state_active_; }
-
- void reset_data() {
- called_set_logging_state_ = false;
- logging_state_active_ = false;
- }
-
- private:
- // autofill::mojom::PasswordAutofillAgent:
- void FillPasswordForm(
- int key,
- const autofill::PasswordFormFillData& form_data) override {}
-
- void SetLoggingState(bool active) override {
- called_set_logging_state_ = true;
- logging_state_active_ = active;
- }
-
- void AutofillUsernameAndPasswordDataReceived(
- const autofill::FormsPredictionsMap& predictions) override {}
-
- void FindFocusedPasswordForm(
- const FindFocusedPasswordFormCallback& callback) override {}
-
- // Records whether SetLoggingState() gets called.
- bool called_set_logging_state_;
- // Records data received via SetLoggingState() call.
- bool logging_state_active_;
-
- mojo::Binding<autofill::mojom::PasswordAutofillAgent> binding_;
-};
-
} // namespace
class ContentPasswordManagerDriverTest
@@ -98,24 +50,18 @@
content::RenderViewHostTestHarness::SetUp();
ON_CALL(password_manager_client_, GetLogManager())
.WillByDefault(Return(&log_manager_));
-
- shell::InterfaceProvider* remote_interfaces =
- web_contents()->GetMainFrame()->GetRemoteInterfaces();
- shell::InterfaceProvider::TestApi test_api(remote_interfaces);
- test_api.SetBinderForName(
- autofill::mojom::PasswordAutofillAgent::Name_,
- base::Bind(&FakePasswordAutofillAgent::BindRequest,
- base::Unretained(&fake_agent_)));
}
bool WasLoggingActivationMessageSent(bool* activation_flag) {
- base::RunLoop().RunUntilIdle();
- if (!fake_agent_.called_set_logging_state())
+ const uint32_t kMsgID = AutofillMsg_SetLoggingState::ID;
+ const IPC::Message* message =
+ process()->sink().GetFirstMessageMatching(kMsgID);
+ if (!message)
return false;
-
- if (activation_flag)
- *activation_flag = fake_agent_.logging_state_active();
- fake_agent_.reset_data();
+ std::tuple<bool> param;
+ AutofillMsg_SetLoggingState::Read(message, &param);
+ *activation_flag = std::get<0>(param);
+ process()->sink().ClearMessages();
return true;
}
@@ -123,8 +69,6 @@
MockLogManager log_manager_;
MockPasswordManagerClient password_manager_client_;
autofill::TestAutofillClient autofill_client_;
-
- FakePasswordAutofillAgent fake_agent_;
};
TEST_P(ContentPasswordManagerDriverTest,
@@ -133,6 +77,7 @@
std::unique_ptr<ContentPasswordManagerDriver> driver(
new ContentPasswordManagerDriver(main_rfh(), &password_manager_client_,
&autofill_client_));
+ process()->sink().ClearMessages();
EXPECT_CALL(log_manager_, IsLoggingActive())
.WillRepeatedly(Return(should_allow_logging));
@@ -157,10 +102,11 @@
EXPECT_CALL(log_manager_, IsLoggingActive())
.WillRepeatedly(Return(should_allow_logging));
driver->SendLoggingAvailability();
- WasLoggingActivationMessageSent(nullptr);
+ process()->sink().ClearMessages();
// Ping the driver for logging activity update.
- driver->PasswordAutofillAgentConstructed();
+ AutofillHostMsg_PasswordAutofillAgentConstructed msg(0);
+ driver->HandleMessage(msg);
bool logging_activated = false;
EXPECT_TRUE(WasLoggingActivationMessageSent(&logging_activated));

Powered by Google App Engine
This is Rietveld 408576698