Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Aniona
java-client
提交
c4060efb
J
java-client
项目概览
Aniona
/
java-client
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
java-client
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
c4060efb
编写于
11月 09, 2020
作者:
V
Valery Yatsynovich
提交者:
GitHub
11月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: Add ability to set multiple settings (#1409)
上级
5999cebe
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
77 addition
and
6 deletion
+77
-6
src/main/java/io/appium/java_client/HasSettings.java
src/main/java/io/appium/java_client/HasSettings.java
+28
-0
src/main/java/io/appium/java_client/MobileCommand.java
src/main/java/io/appium/java_client/MobileCommand.java
+5
-2
src/test/java/io/appium/java_client/android/SettingTest.java
src/test/java/io/appium/java_client/android/SettingTest.java
+21
-0
src/test/java/io/appium/java_client/ios/SettingTest.java
src/test/java/io/appium/java_client/ios/SettingTest.java
+23
-4
未找到文件。
src/main/java/io/appium/java_client/HasSettings.java
浏览文件 @
c4060efb
...
...
@@ -21,7 +21,10 @@ import static io.appium.java_client.MobileCommand.setSettingsCommand;
import
org.openqa.selenium.remote.Response
;
import
java.util.EnumMap
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.stream.Collectors
;
public
interface
HasSettings
extends
ExecutesMethod
{
...
...
@@ -52,6 +55,31 @@ public interface HasSettings extends ExecutesMethod {
return
this
;
}
/**
* Sets settings for this test session.
*
* @param settings a map with settings, where key is the setting name you wish to set and value is the value of
* the setting.
* @return Self instance for chaining.
*/
default
HasSettings
setSettings
(
EnumMap
<
Setting
,
Object
>
settings
)
{
Map
<
String
,
Object
>
convertedSettings
=
settings
.
entrySet
().
stream
()
.
collect
(
Collectors
.
toMap
(
e
->
e
.
getKey
().
toString
(),
Entry:
:
getValue
));
return
setSettings
(
convertedSettings
);
}
/**
* Sets settings for this test session.
*
* @param settings a map with settings, where key is the setting name you wish to set and value is the value of
* the setting.
* @return Self instance for chaining.
*/
default
HasSettings
setSettings
(
Map
<
String
,
Object
>
settings
)
{
CommandExecutionHelper
.
execute
(
this
,
setSettingsCommand
(
settings
));
return
this
;
}
/**
* Get settings stored for this test session It's probably better to use a
* convenience function, rather than use this function directly. Try finding
...
...
src/main/java/io/appium/java_client/MobileCommand.java
浏览文件 @
c4060efb
...
...
@@ -481,8 +481,11 @@ public class MobileCommand {
}
public
static
Map
.
Entry
<
String
,
Map
<
String
,
?>>
setSettingsCommand
(
String
setting
,
Object
value
)
{
return
new
AbstractMap
.
SimpleEntry
<>(
SET_SETTINGS
,
prepareArguments
(
"settings"
,
prepareArguments
(
setting
,
value
)));
return
setSettingsCommand
(
prepareArguments
(
setting
,
value
));
}
public
static
Map
.
Entry
<
String
,
Map
<
String
,
?>>
setSettingsCommand
(
Map
<
String
,
Object
>
settings
)
{
return
new
AbstractMap
.
SimpleEntry
<>(
SET_SETTINGS
,
prepareArguments
(
"settings"
,
settings
));
}
/**
...
...
src/test/java/io/appium/java_client/android/SettingTest.java
浏览文件 @
c4060efb
...
...
@@ -4,6 +4,9 @@ import io.appium.java_client.Setting;
import
org.junit.Test
;
import
java.time.Duration
;
import
java.util.EnumMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
@@ -103,6 +106,24 @@ public class SettingTest extends BaseAndroidTest {
.
get
(
"shouldUseCompactResponses"
));
}
@Test
public
void
setMultipleSettings
()
{
EnumMap
<
Setting
,
Object
>
enumSettings
=
new
EnumMap
<>(
Setting
.
class
);
enumSettings
.
put
(
Setting
.
IGNORE_UNIMPORTANT_VIEWS
,
true
);
enumSettings
.
put
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
,
"type,label"
);
driver
.
setSettings
(
enumSettings
);
Map
<
String
,
Object
>
actual
=
driver
.
getSettings
();
assertEquals
(
true
,
actual
.
get
(
Setting
.
IGNORE_UNIMPORTANT_VIEWS
.
toString
()));
assertEquals
(
"type,label"
,
actual
.
get
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
.
toString
()));
Map
<
String
,
Object
>
mapSettings
=
new
HashMap
<>();
mapSettings
.
put
(
Setting
.
IGNORE_UNIMPORTANT_VIEWS
.
toString
(),
false
);
mapSettings
.
put
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
.
toString
(),
""
);
driver
.
setSettings
(
mapSettings
);
actual
=
driver
.
getSettings
();
assertEquals
(
false
,
actual
.
get
(
Setting
.
IGNORE_UNIMPORTANT_VIEWS
.
toString
()));
assertEquals
(
""
,
actual
.
get
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
.
toString
()));
}
private
void
assertJSONElementContains
(
Setting
setting
,
long
value
)
{
assertEquals
(
driver
.
getSettings
().
get
(
setting
.
toString
()),
value
);
}
...
...
src/test/java/io/appium/java_client/ios/SettingTest.java
浏览文件 @
c4060efb
...
...
@@ -22,6 +22,9 @@ import org.junit.Test;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
java.util.EnumMap
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
SettingTest
extends
AppIOSTest
{
...
...
@@ -34,10 +37,10 @@ public class SettingTest extends AppIOSTest {
}
@Test
public
void
testSetElementResponseAttributes
()
{
assertEquals
(
"
type,label
"
,
driver
.
getSettings
()
assertEquals
(
""
,
driver
.
getSettings
()
.
get
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
.
toString
()));
driver
.
setElementResponseAttributes
(
"
name
"
);
assertEquals
(
"
name
"
,
driver
.
getSettings
()
driver
.
setElementResponseAttributes
(
"
type,label
"
);
assertEquals
(
"
type,label
"
,
driver
.
getSettings
()
.
get
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
.
toString
()));
}
...
...
@@ -94,5 +97,21 @@ public class SettingTest extends AppIOSTest {
.
get
(
"shouldUseCompactResponses"
));
}
@Test
public
void
setMultipleSettings
()
{
EnumMap
<
Setting
,
Object
>
enumSettings
=
new
EnumMap
<>(
Setting
.
class
);
enumSettings
.
put
(
Setting
.
IGNORE_UNIMPORTANT_VIEWS
,
true
);
enumSettings
.
put
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
,
"type,label"
);
driver
.
setSettings
(
enumSettings
);
Map
<
String
,
Object
>
actual
=
driver
.
getSettings
();
assertEquals
(
true
,
actual
.
get
(
Setting
.
IGNORE_UNIMPORTANT_VIEWS
.
toString
()));
assertEquals
(
"type,label"
,
actual
.
get
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
.
toString
()));
Map
<
String
,
Object
>
mapSettings
=
new
HashMap
<>();
mapSettings
.
put
(
Setting
.
IGNORE_UNIMPORTANT_VIEWS
.
toString
(),
false
);
mapSettings
.
put
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
.
toString
(),
""
);
driver
.
setSettings
(
mapSettings
);
actual
=
driver
.
getSettings
();
assertEquals
(
false
,
actual
.
get
(
Setting
.
IGNORE_UNIMPORTANT_VIEWS
.
toString
()));
assertEquals
(
""
,
actual
.
get
(
Setting
.
ELEMENT_RESPONSE_ATTRIBUTES
.
toString
()));
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录