Skip to content

Commit

Permalink
ash: Convert MOCK_METHOD#() calls to MOCK_METHOD()
Browse files Browse the repository at this point in the history
The compiler can count our arguments for us. go/totw/164

This also revealed an unused mock method for exo::KeyboardDelegate.

Bug: none
Test: ash_unittests
Change-Id: I8b864c2766986c8df5b0fd74f9ac2eb28de3def7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1749708
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Commit-Queue: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686185}
  • Loading branch information
James Cook authored and Commit Bot committed Aug 12, 2019
1 parent 7d5b952 commit 7da53a0
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 72 deletions.
21 changes: 13 additions & 8 deletions ash/assistant/assistant_notification_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ class AssistantNotificationModelObserverMock
AssistantNotificationModelObserverMock() = default;
~AssistantNotificationModelObserverMock() override = default;

MOCK_METHOD1(OnNotificationAdded,
void(const AssistantNotification* notification));
MOCK_METHOD1(OnNotificationUpdated,
void(const AssistantNotification* notification));
MOCK_METHOD2(OnNotificationRemoved,
void(const AssistantNotification* notification,
bool from_server));
MOCK_METHOD1(OnAllNotificationsRemoved, void(bool from_server));
MOCK_METHOD(void,
OnNotificationAdded,
(const AssistantNotification* notification),
(override));
MOCK_METHOD(void,
OnNotificationUpdated,
(const AssistantNotification* notification),
(override));
MOCK_METHOD(void,
OnNotificationRemoved,
(const AssistantNotification* notification, bool from_server),
(override));
MOCK_METHOD(void, OnAllNotificationsRemoved, (bool from_server), (override));

private:
DISALLOW_COPY_AND_ASSIGN(AssistantNotificationModelObserverMock);
Expand Down
4 changes: 2 additions & 2 deletions ash/keyboard/ui/keyboard_ui_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ TEST_F(KeyboardControllerAnimationTest, FloatingKeyboardEnsureCaretInWorkArea) {
// Mock TextInputClient to intercept calls to EnsureCaretNotInRect.
struct MockTextInputClient : public ui::DummyTextInputClient {
MockTextInputClient() : DummyTextInputClient(ui::TEXT_INPUT_TYPE_TEXT) {}
MOCK_METHOD1(EnsureCaretNotInRect, void(const gfx::Rect&));
MOCK_METHOD(void, EnsureCaretNotInRect, (const gfx::Rect&), (override));
};

// Floating keyboard should call EnsureCaretNotInRect with the empty rect.
Expand Down Expand Up @@ -745,7 +745,7 @@ class MockKeyboardControllerObserver : public ash::KeyboardControllerObserver {
~MockKeyboardControllerObserver() override = default;

// KeyboardControllerObserver:
MOCK_METHOD1(OnKeyboardEnabledChanged, void(bool is_enabled));
MOCK_METHOD(void, OnKeyboardEnabledChanged, (bool is_enabled), (override));

private:
DISALLOW_COPY_AND_ASSIGN(MockKeyboardControllerObserver);
Expand Down
107 changes: 61 additions & 46 deletions ash/login/mock_login_screen_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,28 @@ class MockLoginScreenClient : public LoginScreenClient {
MockLoginScreenClient();
~MockLoginScreenClient() override;

MOCK_METHOD4(AuthenticateUserWithPasswordOrPin_,
void(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin,
base::OnceCallback<void(bool)>& callback));
MOCK_METHOD2(AuthenticateUserWithExternalBinary_,
void(const AccountId& account_id,
base::OnceCallback<void(bool)>& callback));
MOCK_METHOD1(EnrollUserWithExternalBinary_,
void(base::OnceCallback<void(bool)>& callback));
MOCK_METHOD2(AuthenticateUserWithChallengeResponse_,
void(const AccountId& account_id,
base::OnceCallback<void(bool)>& callback));
MOCK_METHOD3(ValidateParentAccessCode_,
bool(const AccountId& account_id,
const std::string& access_code,
base::Time validation_time));
MOCK_METHOD(void,
AuthenticateUserWithPasswordOrPin_,
(const AccountId& account_id,
const std::string& password,
bool authenticated_by_pin,
base::OnceCallback<void(bool)>& callback));
MOCK_METHOD(void,
AuthenticateUserWithExternalBinary_,
(const AccountId& account_id,
base::OnceCallback<void(bool)>& callback));
MOCK_METHOD(void,
EnrollUserWithExternalBinary_,
(base::OnceCallback<void(bool)> & callback));
MOCK_METHOD(void,
AuthenticateUserWithChallengeResponse_,
(const AccountId& account_id,
base::OnceCallback<void(bool)>& callback));
MOCK_METHOD(bool,
ValidateParentAccessCode_,
(const AccountId& account_id,
const std::string& access_code,
base::Time validation_time));

// Set the result that should be passed to |callback| in
// |AuthenticateUserWithPasswordOrPin| or
Expand Down Expand Up @@ -80,35 +85,45 @@ class MockLoginScreenClient : public LoginScreenClient {
bool ValidateParentAccessCode(const AccountId& account_id,
const std::string& code,
base::Time validation_time) override;
MOCK_METHOD1(AuthenticateUserWithEasyUnlock,
void(const AccountId& account_id));
MOCK_METHOD1(HardlockPod, void(const AccountId& account_id));
MOCK_METHOD1(OnFocusPod, void(const AccountId& account_id));
MOCK_METHOD0(OnNoPodFocused, void());
MOCK_METHOD1(LoadWallpaper, void(const AccountId& account_id));
MOCK_METHOD0(SignOutUser, void());
MOCK_METHOD0(CancelAddUser, void());
MOCK_METHOD0(LoginAsGuest, void());
MOCK_METHOD1(OnMaxIncorrectPasswordAttempted,
void(const AccountId& account_id));
MOCK_METHOD1(FocusLockScreenApps, void(bool reverse));
MOCK_METHOD2(ShowGaiaSignin,
void(bool can_close, const AccountId& prefilled_account));
MOCK_METHOD0(OnRemoveUserWarningShown, void());
MOCK_METHOD1(RemoveUser, void(const AccountId& account_id));
MOCK_METHOD3(LaunchPublicSession,
void(const AccountId& account_id,
const std::string& locale,
const std::string& input_method));
MOCK_METHOD2(RequestPublicSessionKeyboardLayouts,
void(const AccountId& account_id, const std::string& locale));
MOCK_METHOD0(ShowFeedback, void());
MOCK_METHOD0(ShowResetScreen, void());
MOCK_METHOD0(ShowAccountAccessHelpApp, void());
MOCK_METHOD0(ShowLockScreenNotificationSettings, void());
MOCK_METHOD0(FocusOobeDialog, void());
MOCK_METHOD1(OnFocusLeavingSystemTray, void(bool reverse));
MOCK_METHOD0(OnUserActivity, void());
MOCK_METHOD(void,
AuthenticateUserWithEasyUnlock,
(const AccountId& account_id),
(override));
MOCK_METHOD(void, HardlockPod, (const AccountId& account_id), (override));
MOCK_METHOD(void, OnFocusPod, (const AccountId& account_id), (override));
MOCK_METHOD(void, OnNoPodFocused, (), (override));
MOCK_METHOD(void, LoadWallpaper, (const AccountId& account_id), (override));
MOCK_METHOD(void, SignOutUser, (), (override));
MOCK_METHOD(void, CancelAddUser, (), (override));
MOCK_METHOD(void, LoginAsGuest, (), (override));
MOCK_METHOD(void,
OnMaxIncorrectPasswordAttempted,
(const AccountId& account_id),
(override));
MOCK_METHOD(void, FocusLockScreenApps, (bool reverse), (override));
MOCK_METHOD(void,
ShowGaiaSignin,
(bool can_close, const AccountId& prefilled_account),
(override));
MOCK_METHOD(void, OnRemoveUserWarningShown, (), (override));
MOCK_METHOD(void, RemoveUser, (const AccountId& account_id), (override));
MOCK_METHOD(void,
LaunchPublicSession,
(const AccountId& account_id,
const std::string& locale,
const std::string& input_method),
(override));
MOCK_METHOD(void,
RequestPublicSessionKeyboardLayouts,
(const AccountId& account_id, const std::string& locale),
(override));
MOCK_METHOD(void, ShowFeedback, (), (override));
MOCK_METHOD(void, ShowResetScreen, (), (override));
MOCK_METHOD(void, ShowAccountAccessHelpApp, (), (override));
MOCK_METHOD(void, ShowLockScreenNotificationSettings, (), (override));
MOCK_METHOD(void, FocusOobeDialog, (), (override));
MOCK_METHOD(void, OnFocusLeavingSystemTray, (bool reverse), (override));
MOCK_METHOD(void, OnUserActivity, (), (override));

private:
bool authenticate_user_callback_result_ = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,21 @@ class MockKeyboardDelegate : public exo::KeyboardDelegate {
MockKeyboardDelegate() = default;

// Overridden from KeyboardDelegate:
MOCK_METHOD1(OnKeyboardDestroying, void(exo::Keyboard*));
MOCK_CONST_METHOD1(CanAcceptKeyboardEventsForSurface, bool(exo::Surface*));
MOCK_METHOD2(OnKeyboardEnter,
void(exo::Surface*,
const base::flat_map<ui::DomCode, ui::DomCode>&));
MOCK_METHOD1(OnKeyboardLeave, void(exo::Surface*));
MOCK_METHOD3(OnKeyboardKey, uint32_t(base::TimeTicks, ui::DomCode, bool));
MOCK_METHOD1(OnKeyboardModifiers, void(int));
MOCK_METHOD(bool,
CanAcceptKeyboardEventsForSurface,
(exo::Surface*),
(const, override));
MOCK_METHOD(void,
OnKeyboardEnter,
(exo::Surface*,
(const base::flat_map<ui::DomCode, ui::DomCode>&)),
(override));
MOCK_METHOD(void, OnKeyboardLeave, (exo::Surface*), (override));
MOCK_METHOD(uint32_t,
OnKeyboardKey,
(base::TimeTicks, ui::DomCode, bool),
(override));
MOCK_METHOD(void, OnKeyboardModifiers, (int), (override));
};

class FakeNotificationSurface : public exo::NotificationSurface {
Expand Down
21 changes: 13 additions & 8 deletions ash/system/palette/mock_palette_tool_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ class MockPaletteToolDelegate : public PaletteTool::Delegate {
MockPaletteToolDelegate();
~MockPaletteToolDelegate() override;

MOCK_METHOD1(EnableTool, void(PaletteToolId tool_id));
MOCK_METHOD1(DisableTool, void(PaletteToolId tool_id));
MOCK_METHOD0(HidePalette, void());
MOCK_METHOD0(HidePaletteImmediately, void());
MOCK_METHOD0(GetWindow, aura::Window*());
MOCK_METHOD2(RecordPaletteOptionsUsage,
void(PaletteTrayOptions option, PaletteInvocationMethod method));
MOCK_METHOD1(RecordPaletteModeCancellation, void(PaletteModeCancelType type));
MOCK_METHOD(void, EnableTool, (PaletteToolId tool_id), (override));
MOCK_METHOD(void, DisableTool, (PaletteToolId tool_id), (override));
MOCK_METHOD(void, HidePalette, (), (override));
MOCK_METHOD(void, HidePaletteImmediately, (), (override));
MOCK_METHOD(aura::Window*, GetWindow, (), (override));
MOCK_METHOD(void,
RecordPaletteOptionsUsage,
(PaletteTrayOptions option, PaletteInvocationMethod method),
(override));
MOCK_METHOD(void,
RecordPaletteModeCancellation,
(PaletteModeCancelType type),
(override));
};

} // namespace ash
Expand Down

0 comments on commit 7da53a0

Please sign in to comment.