Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
0985255d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
0985255d
编写于
8月 23, 2024
作者:
辛宝Otto
🥊
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 补充动态切换 background 测试用例
上级
9088e1b2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
59 addition
and
15 deletion
+59
-15
pages/CSS/background/background-image.test.js
pages/CSS/background/background-image.test.js
+26
-2
pages/CSS/background/background-image.uvue
pages/CSS/background/background-image.uvue
+33
-13
未找到文件。
pages/CSS/background/background-image.test.js
浏览文件 @
0985255d
...
@@ -8,14 +8,38 @@ describe('background-image-test', () => {
...
@@ -8,14 +8,38 @@ describe('background-image-test', () => {
it
(
'
background-image-screenshot
'
,
async
()
=>
{
it
(
'
background-image-screenshot
'
,
async
()
=>
{
await
page
.
waitFor
(
300
);
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
expect
(
image
).
toSaveImageSnapshot
();
});
});
it
(
'
background-image-select
'
,
async
()
=>
{
it
(
'
background-image-select
'
,
async
()
=>
{
await
page
.
callMethod
(
'
updateBackgroundSelect
'
)
await
page
.
callMethod
(
'
updateBackgroundSelect
'
)
await
page
.
waitFor
(
300
);
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
expect
(
image
).
toSaveImageSnapshot
();
});
});
it
(
'
动态切换 background color
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setBackgroundColor
'
)
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
})
it
(
'
动态切换 background color/image
'
,
async
()
=>
{
await
page
.
callMethod
(
'
setBackgroundImage
'
)
await
page
.
waitFor
(
300
);
const
image
=
await
program
.
screenshot
({
fullPage
:
true
});
expect
(
image
).
toSaveImageSnapshot
();
})
});
});
pages/CSS/background/background-image.uvue
浏览文件 @
0985255d
...
@@ -2,15 +2,20 @@
...
@@ -2,15 +2,20 @@
<!-- #ifdef APP -->
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<scroll-view style="flex:1">
<!-- #endif -->
<!-- #endif -->
<view>
<view>
<!-- 测试iOS平台宽高为0时,设置渐变色会不会导致闪退 -->
<!-- 测试iOS平台宽高为0时,设置渐变色会不会导致闪退 -->
<view style="width: 0px; height: 0px; background-image: linear-gradient(to bottom,#f5f5f5,#eff2f5);"></view>
<view style="width: 0px; height: 0px; background-image: linear-gradient(to bottom,#f5f5f5,#eff2f5);"></view>
<text>不支持背景图片,仅支持linear-gradient方法</text>
<text>不支持背景图片,仅支持linear-gradient方法</text>
<view v-for="(direction) in directionData">
<view v-for="(direction) in directionData">
<text>background-image: linear-gradient({{direction}}, red, yellow)</text>
<text>background-image: linear-gradient({{direction}}, red, yellow)</text>
<view class="common" :style="{'background-image': backgroundSelect ?'linear-gradient('+direction+', red, yellow)':''}"></view>
<view class="common"
:style="{'background-image': backgroundSelect ?'linear-gradient('+direction+', red, yellow)':''}"></view>
</view>
</view>
</view>
<view>
<text>style 动态切换 background</text>
<view @click='changeBg' class="common" :style='testStyle'></view>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
</scroll-view>
</scroll-view>
<!-- #endif -->
<!-- #endif -->
...
@@ -18,24 +23,39 @@
...
@@ -18,24 +23,39 @@
<script>
<script>
export default {
export default {
data(){
data()
{
return {
return {
backgroundSelect : true,
backgroundSelect: true,
directionData: ['to right', 'to left', 'to bottom', 'to top', 'to bottom left', 'to bottom right', 'to top left', 'to top right']
directionData: ['to right', 'to left', 'to bottom', 'to top', 'to bottom left', 'to bottom right', 'to top left', 'to top right'],
testStyle: "background:linear-gradient(to right, red, yellow)"
}
}
},
},
methods: {
methods: {
//供自动化测试使用
//供自动化测试使用
updateBackgroundSelect() {
updateBackgroundSelect() {
this.backgroundSelect = !this.backgroundSelect
this.backgroundSelect = !this.backgroundSelect
},
changeBg() {
const isColor = this.testStyle == "background:blue"
if (isColor) {
this.setBackgroundImage()
} else {
this.setBackgroundColor()
}
},
setBackgroundColor() {
this.testStyle = "background:blue"
},
setBackgroundImage() {
this.testStyle = "background:linear-gradient(to right, red, yellow)"
}
}
}
}
}
}
</script>
</script>
<style>
<style>
.common {
.common {
width: 250px;
width: 250px;
height: 250px;
height: 250px;
}
}
</style>
</style>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录