Skip to content

Commit

Permalink
Fix errors arising from merging master to branch
Browse files Browse the repository at this point in the history
  • Loading branch information
zltnDC committed Sep 12, 2023
1 parent 6b1cb73 commit 5689bdf
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class Automator private constructor() {
delay()
}

fun enterText(text: String, index: Int, keyboardBehavior: KeyboardBehavior) {
fun enterText(text: String, index: Int, keyboardBehavior: Contracts.KeyboardBehavior) {
Logger.d("enterText(text: $text, index: $index)")

val selector = By.clazz(EditText::class.java)
Expand All @@ -187,13 +187,13 @@ class Automator private constructor() {
val uiSelector = UiSelector().className(EditText::class.java).instance(index)
val uiObject = uiDevice.findObject(uiSelector)

if (keyboardBehavior == KeyboardBehavior.SHOW_AND_DISMISS) {
if (keyboardBehavior == Contracts.KeyboardBehavior.showAndDismiss) {
uiObject.click()
}

uiObject.text = text

if (keyboardBehavior == KeyboardBehavior.SHOW_AND_DISMISS) {
if (keyboardBehavior == Contracts.KeyboardBehavior.showAndDismiss) {
pressBack() // Hide keyboard.
}
}
Expand All @@ -203,7 +203,7 @@ class Automator private constructor() {
uiSelector: UiSelector,
bySelector: BySelector,
index: Int,
keyboardBehavior: KeyboardBehavior
keyboardBehavior: Contracts.KeyboardBehavior
) {
Logger.d("enterText($text): $uiSelector, $bySelector")

Expand All @@ -213,13 +213,13 @@ class Automator private constructor() {

val uiObject = uiDevice.findObject(uiSelector).getFromParent(UiSelector().className(EditText::class.java))

if (keyboardBehavior == KeyboardBehavior.SHOW_AND_DISMISS) {
if (keyboardBehavior == Contracts.KeyboardBehavior.showAndDismiss) {
uiObject.click()
}

uiObject.text = text

if (keyboardBehavior == KeyboardBehavior.SHOW_AND_DISMISS) {
if (keyboardBehavior == Contracts.KeyboardBehavior.showAndDismiss) {
pressBack() // Hide keyboard.
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class AutomatorServer(private val automation: Automator) : NativeAutomatorServer
if (request.index != null) {
automation.enterText(
text = request.data,
index = request.index!!.toInt(),
index = request.index.toInt(),
keyboardBehavior = request.keyboardBehavior
)
} else if (request.selector != null) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion packages/patrol/ios/Classes/AutomatorServer/Contracts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ enum RunDartTestResponseResult: String, Codable {
case failure
}

enum KeyboardBehavior: String, Codable {
case showAndDismiss
case alternative
}

enum HandlePermissionRequestCode: String, Codable {
case whileUsing
case onlyThisTime
Expand Down Expand Up @@ -101,7 +106,7 @@ struct EnterTextRequest: Codable {
var appId: String
var index: Int?
var selector: Selector?
var showKeyboard: Bool
var keyboardBehavior: KeyboardBehavior
}

struct SwipeRequest: Codable {
Expand Down
11 changes: 9 additions & 2 deletions packages/patrol/lib/src/native/contracts/contracts.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions packages/patrol/lib/src/native/contracts/contracts.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions packages/patrol/lib/src/native/native_automator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:integration_test/integration_test.dart';
import 'package:meta/meta.dart';
import 'package:patrol/src/binding.dart';
import 'package:patrol/src/native/contracts/contracts.dart';
import 'package:patrol/src/native/contracts/contracts.dart' as contracts;
import 'package:patrol/src/native/contracts/native_automator_client.dart';

/// Thrown when a native action fails.
Expand Down Expand Up @@ -51,12 +52,12 @@ enum KeyboardBehavior {
}

extension on KeyboardBehavior {
EnterTextRequest_KeyboardBehavior get toProtoEnum {
contracts.KeyboardBehavior get toContractsEnum {
switch (this) {
case KeyboardBehavior.showAndDismiss:
return EnterTextRequest_KeyboardBehavior.SHOW_AND_DISMISS;
return contracts.KeyboardBehavior.showAndDismiss;
case KeyboardBehavior.alternative:
return EnterTextRequest_KeyboardBehavior.ALTERNATIVE;
return contracts.KeyboardBehavior.alternative;
}
}
}
Expand Down Expand Up @@ -547,7 +548,7 @@ class NativeAutomator {
appId: appId ?? resolvedAppId,
selector: selector,
keyboardBehavior:
(keyboardBehavior ?? _config.keyboardBehavior).toProtoEnum,
(keyboardBehavior ?? _config.keyboardBehavior).toContractsEnum,
),
),
);
Expand Down Expand Up @@ -581,7 +582,7 @@ class NativeAutomator {
appId: appId ?? resolvedAppId,
index: index,
keyboardBehavior:
(keyboardBehavior ?? _config.keyboardBehavior).toProtoEnum,
(keyboardBehavior ?? _config.keyboardBehavior).toContractsEnum,
),
),
);
Expand Down
7 changes: 6 additions & 1 deletion schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,17 @@ class TapRequest {
late String appId;
}

enum KeyboardBehavior {
showAndDismiss,
alternative,
}

class EnterTextRequest {
late String data;
late String appId;
int? index;
Selector? selector;
late bool showKeyboard;
late KeyboardBehavior keyboardBehavior;
}

class SwipeRequest {
Expand Down

0 comments on commit 5689bdf

Please sign in to comment.