unit_tests: fix mock warnings in AutoFillPopup tests
Use NiceMock to silence warnings about uninteresting mock function calls. Also fix some DISALLOW_COPY_AND_ASSIGNS Bug: 1010217 Change-Id: I622f27120e0e111f3daa1573b17ceded4ca57910 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2955891 Reviewed-by: Evan Stade <estade@chromium.org> Commit-Queue: David Bienvenu <davidbienvenu@chromium.org> Cr-Commit-Position: refs/heads/master@{#891765}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
233101efdc
commit
ec51a9823f
chrome/browser/ui
autofill
views
components/autofill/core/browser
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "base/macros.h"
|
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
@ -61,6 +60,8 @@ const BrowserAutofillManager::AutofillDownloadManagerState kDownloadState =
|
|||||||
class MockAutofillClient : public autofill::TestAutofillClient {
|
class MockAutofillClient : public autofill::TestAutofillClient {
|
||||||
public:
|
public:
|
||||||
MockAutofillClient() : prefs_(autofill::test::PrefServiceForTesting()) {}
|
MockAutofillClient() : prefs_(autofill::test::PrefServiceForTesting()) {}
|
||||||
|
MockAutofillClient(MockAutofillClient&) = delete;
|
||||||
|
MockAutofillClient& operator=(MockAutofillClient&) = delete;
|
||||||
~MockAutofillClient() override = default;
|
~MockAutofillClient() override = default;
|
||||||
|
|
||||||
PrefService* GetPrefs() override {
|
PrefService* GetPrefs() override {
|
||||||
@ -70,8 +71,6 @@ class MockAutofillClient : public autofill::TestAutofillClient {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<PrefService> prefs_;
|
std::unique_ptr<PrefService> prefs_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MockAutofillClient);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockAutofillDriver : public ContentAutofillDriver {
|
class MockAutofillDriver : public ContentAutofillDriver {
|
||||||
@ -84,11 +83,11 @@ class MockAutofillDriver : public ContentAutofillDriver {
|
|||||||
kDownloadState,
|
kDownloadState,
|
||||||
AutofillManager::AutofillManagerFactoryCallback()) {}
|
AutofillManager::AutofillManagerFactoryCallback()) {}
|
||||||
|
|
||||||
|
MockAutofillDriver(MockAutofillDriver&) = delete;
|
||||||
|
MockAutofillDriver& operator=(MockAutofillDriver&) = delete;
|
||||||
|
|
||||||
~MockAutofillDriver() override = default;
|
~MockAutofillDriver() override = default;
|
||||||
MOCK_CONST_METHOD0(GetAxTreeId, ui::AXTreeID());
|
MOCK_CONST_METHOD0(GetAxTreeId, ui::AXTreeID());
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MockAutofillDriver);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockBrowserAutofillManager : public BrowserAutofillManager {
|
class MockBrowserAutofillManager : public BrowserAutofillManager {
|
||||||
@ -98,10 +97,9 @@ class MockBrowserAutofillManager : public BrowserAutofillManager {
|
|||||||
client,
|
client,
|
||||||
client->GetPersonalDataManager(),
|
client->GetPersonalDataManager(),
|
||||||
client->GetAutocompleteHistoryManager()) {}
|
client->GetAutocompleteHistoryManager()) {}
|
||||||
|
MockBrowserAutofillManager(MockBrowserAutofillManager&) = delete;
|
||||||
|
MockBrowserAutofillManager& operator=(MockBrowserAutofillManager&) = delete;
|
||||||
~MockBrowserAutofillManager() override = default;
|
~MockBrowserAutofillManager() override = default;
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MockBrowserAutofillManager);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockAutofillExternalDelegate : public AutofillExternalDelegate {
|
class MockAutofillExternalDelegate : public AutofillExternalDelegate {
|
||||||
@ -127,6 +125,8 @@ class MockAutofillExternalDelegate : public AutofillExternalDelegate {
|
|||||||
class MockAutofillPopupView : public AutofillPopupView {
|
class MockAutofillPopupView : public AutofillPopupView {
|
||||||
public:
|
public:
|
||||||
MockAutofillPopupView() = default;
|
MockAutofillPopupView() = default;
|
||||||
|
MockAutofillPopupView(MockAutofillPopupView&) = delete;
|
||||||
|
MockAutofillPopupView& operator=(MockAutofillPopupView&) = delete;
|
||||||
~MockAutofillPopupView() override = default;
|
~MockAutofillPopupView() override = default;
|
||||||
|
|
||||||
MOCK_METHOD0(Show, void());
|
MOCK_METHOD0(Show, void());
|
||||||
@ -136,9 +136,6 @@ class MockAutofillPopupView : public AutofillPopupView {
|
|||||||
absl::optional<int> current_row_selection));
|
absl::optional<int> current_row_selection));
|
||||||
MOCK_METHOD0(OnSuggestionsChanged, void());
|
MOCK_METHOD0(OnSuggestionsChanged, void());
|
||||||
MOCK_METHOD0(GetAxUniqueId, absl::optional<int32_t>());
|
MOCK_METHOD0(GetAxUniqueId, absl::optional<int32_t>());
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MockAutofillPopupView);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestAutofillPopupController : public AutofillPopupControllerImpl {
|
class TestAutofillPopupController : public AutofillPopupControllerImpl {
|
||||||
@ -182,6 +179,8 @@ class TestAutofillPopupController : public AutofillPopupControllerImpl {
|
|||||||
class MockAxTreeManager : public ui::AXTreeManager {
|
class MockAxTreeManager : public ui::AXTreeManager {
|
||||||
public:
|
public:
|
||||||
MockAxTreeManager() = default;
|
MockAxTreeManager() = default;
|
||||||
|
MockAxTreeManager(MockAxTreeManager&) = delete;
|
||||||
|
MockAxTreeManager& operator=(MockAxTreeManager&) = delete;
|
||||||
~MockAxTreeManager() = default;
|
~MockAxTreeManager() = default;
|
||||||
|
|
||||||
MOCK_CONST_METHOD2(GetNodeFromTree,
|
MOCK_CONST_METHOD2(GetNodeFromTree,
|
||||||
@ -196,33 +195,28 @@ class MockAxTreeManager : public ui::AXTreeManager {
|
|||||||
MOCK_CONST_METHOD0(GetParentTreeID, ui::AXTreeID());
|
MOCK_CONST_METHOD0(GetParentTreeID, ui::AXTreeID());
|
||||||
MOCK_CONST_METHOD0(GetRootAsAXNode, ui::AXNode*());
|
MOCK_CONST_METHOD0(GetRootAsAXNode, ui::AXNode*());
|
||||||
MOCK_CONST_METHOD0(GetParentNodeFromParentTreeAsAXNode, ui::AXNode*());
|
MOCK_CONST_METHOD0(GetParentNodeFromParentTreeAsAXNode, ui::AXNode*());
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MockAxTreeManager);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockAxPlatformNodeDelegate : public ui::AXPlatformNodeDelegateBase {
|
class MockAxPlatformNodeDelegate : public ui::AXPlatformNodeDelegateBase {
|
||||||
public:
|
public:
|
||||||
MockAxPlatformNodeDelegate() = default;
|
MockAxPlatformNodeDelegate() = default;
|
||||||
|
MockAxPlatformNodeDelegate(MockAxPlatformNodeDelegate&) = delete;
|
||||||
|
MockAxPlatformNodeDelegate& operator=(MockAxPlatformNodeDelegate&) = delete;
|
||||||
~MockAxPlatformNodeDelegate() override = default;
|
~MockAxPlatformNodeDelegate() override = default;
|
||||||
|
|
||||||
MOCK_METHOD1(GetFromNodeID, ui::AXPlatformNode*(int32_t id));
|
MOCK_METHOD1(GetFromNodeID, ui::AXPlatformNode*(int32_t id));
|
||||||
MOCK_METHOD2(GetFromTreeIDAndNodeID,
|
MOCK_METHOD2(GetFromTreeIDAndNodeID,
|
||||||
ui::AXPlatformNode*(const ui::AXTreeID& tree_id, int32_t id));
|
ui::AXPlatformNode*(const ui::AXTreeID& tree_id, int32_t id));
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MockAxPlatformNodeDelegate);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class MockAxPlatformNode : public ui::AXPlatformNodeBase {
|
class MockAxPlatformNode : public ui::AXPlatformNodeBase {
|
||||||
public:
|
public:
|
||||||
MockAxPlatformNode() = default;
|
MockAxPlatformNode() = default;
|
||||||
|
MockAxPlatformNode(MockAxPlatformNode&) = delete;
|
||||||
|
MockAxPlatformNode& operator=(MockAxPlatformNode&) = delete;
|
||||||
~MockAxPlatformNode() override = default;
|
~MockAxPlatformNode() override = default;
|
||||||
|
|
||||||
MOCK_CONST_METHOD0(GetDelegate, ui::AXPlatformNodeDelegate*());
|
MOCK_CONST_METHOD0(GetDelegate, ui::AXPlatformNodeDelegate*());
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(MockAxPlatformNode);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr absl::optional<int> kNoSelection;
|
static constexpr absl::optional<int> kNoSelection;
|
||||||
@ -274,7 +268,9 @@ class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness {
|
|||||||
return autofill_popup_controller_;
|
return autofill_popup_controller_;
|
||||||
}
|
}
|
||||||
|
|
||||||
MockAutofillExternalDelegate* delegate() { return external_delegate_.get(); }
|
NiceMock<MockAutofillExternalDelegate>* delegate() {
|
||||||
|
return external_delegate_.get();
|
||||||
|
}
|
||||||
|
|
||||||
MockAutofillPopupView* autofill_popup_view() {
|
MockAutofillPopupView* autofill_popup_view() {
|
||||||
return autofill_popup_view_.get();
|
return autofill_popup_view_.get();
|
||||||
@ -293,6 +289,10 @@ class AutofillPopupControllerAccessibilityUnitTest
|
|||||||
public:
|
public:
|
||||||
AutofillPopupControllerAccessibilityUnitTest()
|
AutofillPopupControllerAccessibilityUnitTest()
|
||||||
: accessibility_mode_setter_(ui::AXMode::kScreenReader) {}
|
: accessibility_mode_setter_(ui::AXMode::kScreenReader) {}
|
||||||
|
AutofillPopupControllerAccessibilityUnitTest(
|
||||||
|
AutofillPopupControllerAccessibilityUnitTest&) = delete;
|
||||||
|
AutofillPopupControllerAccessibilityUnitTest& operator=(
|
||||||
|
AutofillPopupControllerAccessibilityUnitTest&) = delete;
|
||||||
~AutofillPopupControllerAccessibilityUnitTest() override = default;
|
~AutofillPopupControllerAccessibilityUnitTest() override = default;
|
||||||
|
|
||||||
std::unique_ptr<NiceMock<MockAutofillExternalDelegate>>
|
std::unique_ptr<NiceMock<MockAutofillExternalDelegate>>
|
||||||
@ -309,9 +309,6 @@ class AutofillPopupControllerAccessibilityUnitTest
|
|||||||
std::unique_ptr<MockBrowserAutofillManager> autofill_manager_;
|
std::unique_ptr<MockBrowserAutofillManager> autofill_manager_;
|
||||||
std::unique_ptr<NiceMock<MockAutofillDriver>> autofill_driver_;
|
std::unique_ptr<NiceMock<MockAutofillDriver>> autofill_driver_;
|
||||||
content::testing::ScopedContentAXModeSetter accessibility_mode_setter_;
|
content::testing::ScopedContentAXModeSetter accessibility_mode_setter_;
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AutofillPopupControllerAccessibilityUnitTest);
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -596,8 +593,8 @@ TEST_F(AutofillPopupControllerUnitTest, GetOrCreate) {
|
|||||||
ContentAutofillDriverFactory::FromWebContents(web_contents());
|
ContentAutofillDriverFactory::FromWebContents(web_contents());
|
||||||
ContentAutofillDriver* driver =
|
ContentAutofillDriver* driver =
|
||||||
factory->DriverForFrame(web_contents()->GetMainFrame());
|
factory->DriverForFrame(web_contents()->GetMainFrame());
|
||||||
MockAutofillExternalDelegate delegate(driver->browser_autofill_manager(),
|
NiceMock<MockAutofillExternalDelegate> delegate(
|
||||||
driver);
|
driver->browser_autofill_manager(), driver);
|
||||||
|
|
||||||
WeakPtr<AutofillPopupControllerImpl> controller =
|
WeakPtr<AutofillPopupControllerImpl> controller =
|
||||||
AutofillPopupControllerImpl::GetOrCreate(
|
AutofillPopupControllerImpl::GetOrCreate(
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include "ui/views/test/ax_event_counter.h"
|
#include "ui/views/test/ax_event_counter.h"
|
||||||
#include "ui/views/widget/widget_utils.h"
|
#include "ui/views/widget/widget_utils.h"
|
||||||
|
|
||||||
|
using testing::NiceMock;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct TypeClicks {
|
struct TypeClicks {
|
||||||
@ -52,6 +54,9 @@ const struct TypeClicks kClickTestCase[] = {
|
|||||||
class AutofillPopupViewNativeViewsTest : public ChromeViewsTestBase {
|
class AutofillPopupViewNativeViewsTest : public ChromeViewsTestBase {
|
||||||
public:
|
public:
|
||||||
AutofillPopupViewNativeViewsTest() = default;
|
AutofillPopupViewNativeViewsTest() = default;
|
||||||
|
AutofillPopupViewNativeViewsTest(AutofillPopupViewNativeViewsTest&) = delete;
|
||||||
|
AutofillPopupViewNativeViewsTest& operator=(
|
||||||
|
AutofillPopupViewNativeViewsTest&) = delete;
|
||||||
~AutofillPopupViewNativeViewsTest() override = default;
|
~AutofillPopupViewNativeViewsTest() override = default;
|
||||||
|
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
@ -82,12 +87,9 @@ class AutofillPopupViewNativeViewsTest : public ChromeViewsTestBase {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<autofill::AutofillPopupViewNativeViews> view_;
|
std::unique_ptr<autofill::AutofillPopupViewNativeViews> view_;
|
||||||
autofill::MockAutofillPopupController autofill_popup_controller_;
|
NiceMock<autofill::MockAutofillPopupController> autofill_popup_controller_;
|
||||||
std::unique_ptr<views::Widget> widget_;
|
std::unique_ptr<views::Widget> widget_;
|
||||||
std::unique_ptr<ui::test::EventGenerator> generator_;
|
std::unique_ptr<ui::test::EventGenerator> generator_;
|
||||||
|
|
||||||
private:
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewNativeViewsTest);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class AutofillPopupViewNativeViewsForEveryTypeTest
|
class AutofillPopupViewNativeViewsForEveryTypeTest
|
||||||
|
@ -225,7 +225,8 @@ class TestAutofillClient : public AutofillClient {
|
|||||||
return save_credit_card_options_.value();
|
return save_credit_card_options_.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
MockAutocompleteHistoryManager* GetMockAutocompleteHistoryManager() {
|
::testing::NiceMock<MockAutocompleteHistoryManager>*
|
||||||
|
GetMockAutocompleteHistoryManager() {
|
||||||
return &mock_autocomplete_history_manager_;
|
return &mock_autocomplete_history_manager_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +254,8 @@ class TestAutofillClient : public AutofillClient {
|
|||||||
syncer::SyncService* test_sync_service_ = nullptr;
|
syncer::SyncService* test_sync_service_ = nullptr;
|
||||||
TestAddressNormalizer test_address_normalizer_;
|
TestAddressNormalizer test_address_normalizer_;
|
||||||
TestPersonalDataManager test_personal_data_manager_;
|
TestPersonalDataManager test_personal_data_manager_;
|
||||||
MockAutocompleteHistoryManager mock_autocomplete_history_manager_;
|
::testing::NiceMock<MockAutocompleteHistoryManager>
|
||||||
|
mock_autocomplete_history_manager_;
|
||||||
std::unique_ptr<AutofillOfferManager> autofill_offer_manager_;
|
std::unique_ptr<AutofillOfferManager> autofill_offer_manager_;
|
||||||
|
|
||||||
// NULL by default.
|
// NULL by default.
|
||||||
|
Reference in New Issue
Block a user