-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Autofill Assistant] Move |ClickOrTap| chain to util
This finally moves the action chain used for |ClickOrTap| (and as a result also |SendKeyboardInput|) to the util. The chain for |SetFieldValue| still remains, as extracting that one requires a bit more work to be done. Bug: b/158153191 Change-Id: I255ed476f1e55f4ac8dd5aececf49a9cf8143b0a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276266 Commit-Queue: Sandro Maggi <sandromaggi@google.com> Reviewed-by: Clemens Arbesser <arbesser@google.com> Cr-Commit-Position: refs/heads/master@{#785705}
- Loading branch information
sandromaggi
authored and
Commit Bot
committed
Jul 7, 2020
1 parent
f738ecd
commit 0745dfd
Showing
12 changed files
with
444 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
components/autofill_assistant/browser/actions/click_action_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "components/autofill_assistant/browser/actions/click_action.h" | ||
|
||
#include "base/test/gmock_callback_support.h" | ||
#include "base/test/mock_callback.h" | ||
#include "components/autofill_assistant/browser/actions/action_test_utils.h" | ||
#include "components/autofill_assistant/browser/actions/mock_action_delegate.h" | ||
#include "components/autofill_assistant/browser/selector.h" | ||
#include "components/autofill_assistant/browser/service.pb.h" | ||
#include "testing/gmock/include/gmock/gmock.h" | ||
|
||
namespace autofill_assistant { | ||
namespace { | ||
|
||
using ::base::test::RunOnceCallback; | ||
using ::testing::_; | ||
using ::testing::InSequence; | ||
using ::testing::Pointee; | ||
using ::testing::Property; | ||
|
||
class ClickActionTest : public testing::Test { | ||
public: | ||
ClickActionTest() {} | ||
|
||
void SetUp() override {} | ||
|
||
protected: | ||
void Run() { | ||
ActionProto action_proto; | ||
*action_proto.mutable_click() = proto_; | ||
ClickAction action(&mock_action_delegate_, action_proto); | ||
action.ProcessAction(callback_.Get()); | ||
} | ||
|
||
MockActionDelegate mock_action_delegate_; | ||
base::MockCallback<Action::ProcessActionCallback> callback_; | ||
ClickProto proto_; | ||
}; | ||
|
||
TEST_F(ClickActionTest, EmptySelectorFails) { | ||
EXPECT_CALL( | ||
callback_, | ||
Run(Pointee(Property(&ProcessedActionProto::status, INVALID_SELECTOR)))); | ||
Run(); | ||
} | ||
|
||
TEST_F(ClickActionTest, CheckExpectedCallChain) { | ||
InSequence sequence; | ||
|
||
Selector selector({"#click"}); | ||
*proto_.mutable_element_to_click() = selector.proto; | ||
proto_.set_click_type(ClickType::CLICK); | ||
|
||
Selector expected_selector = selector; | ||
expected_selector.MustBeVisible(); | ||
EXPECT_CALL(mock_action_delegate_, | ||
OnShortWaitForElement(expected_selector, _)) | ||
.WillOnce(RunOnceCallback<1>(OkClientStatus())); | ||
auto expected_element = | ||
test_util::MockFindElement(mock_action_delegate_, expected_selector); | ||
EXPECT_CALL(mock_action_delegate_, WaitForDocumentToBecomeInteractive( | ||
EqualsElement(expected_element), _)) | ||
.WillOnce(RunOnceCallback<1>(OkClientStatus())); | ||
EXPECT_CALL(mock_action_delegate_, | ||
ScrollIntoView(EqualsElement(expected_element), _)) | ||
.WillOnce(RunOnceCallback<1>(OkClientStatus())); | ||
EXPECT_CALL( | ||
mock_action_delegate_, | ||
ClickOrTapElement(EqualsElement(expected_element), ClickType::CLICK, _)) | ||
.WillOnce(RunOnceCallback<2>(OkClientStatus())); | ||
|
||
EXPECT_CALL( | ||
callback_, | ||
Run(Pointee(Property(&ProcessedActionProto::status, ACTION_APPLIED)))); | ||
Run(); | ||
} | ||
|
||
} // namespace | ||
} // namespace autofill_assistant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.