提交 ab3db6c4 编写于 作者: Y yangbo

fix picker xts

Signed-off-by: Nyangbo <yangbo258@huawei.com>
上级 977de50b
......@@ -13,10 +13,6 @@
"type": "ShellKit",
"pre-push": [],
"run-command": [
"rm -rf /storage/media/100/local/files/*",
"rm -rf /data/app/el2/100/database/com.ohos.medialibrary.medialibrarydata/*",
"mkdir -pv /storage/media/100/local/files/{Pictures,Videos,Audios,Documents}",
"mkdir -p /storage/media/100/local/temp",
"param set persist.ace.testmode.enabled 1",
"power-shell wakeup",
"uinput -T -d 300 600 -m 300 600 300 100 -u 300 100",
......@@ -26,32 +22,19 @@
{
"type": "PushKit",
"pre-push": [],
"push": [
"./resource/medialibrary/01.jpg ->/storage/media/100/local/temp",
"./resource/medialibrary/01.mp3 ->/storage/media/100/local/temp",
"./resource/medialibrary/01.mp4 ->/storage/media/100/local/temp",
"./resource/medialibrary/01.dat ->/storage/media/100/local/temp"
]
"push": []
},
{
"type": "ShellKit",
"run-command": [
"cp /storage/media/100/local/temp/01.jpg /storage/media/100/local/files/Pictures/01.jpg",
"cp /storage/media/100/local/temp/01.mp3 /storage/media/100/local/files/Audios/01.mp3",
"cp /storage/media/100/local/temp/01.mp4 /storage/media/100/local/files/Videos/01.mp4",
"cp /storage/media/100/local/temp/01.dat /storage/media/100/local/files/Documents/01.dat",
"chmod -R 777 /storage/media/100/local/files/*",
"chmod -R 777 /data/service/el2/100/hmdfs/account/files/*",
"hilog -Q pidoff",
"hilog -p off",
"hilog -b I",
"hilog -b D -D 0xD002B70",
"scanner",
"sleep 10"
],
"teardown-command": [
"hilog -b X -D 0xD002B70"
"reboot"
]
},
{
......
......@@ -13,177 +13,22 @@
* limitations under the License.
*/
import { Driver, ON } from '@ohos.UiTest'
import abilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
export async function getPermission(context) {
var permissions=['ohos.permission.START_ABILITIES_FROM_BACKGROUND']
context.requestPermissionsFromUser(permissions,(err,result) => {})
}
export async function doSingleSelect(testNum) {
let driver = Driver.create();
await driver.delayMs(1000);
let columns = await driver.findComponents(ON.type("Column").clickable(true));
console.info(`${testNum}::doSingleSelect columns: ${columns}`);
if (columns != undefined) {
await columns[columns.length - 1].click();
await driver.delayMs(1000);
}
let on = ON.text("选择图片");
let rows = await driver.findComponents(ON.isAfter(on).type("Row").clickable(true));
console.info(`${testNum}::doSingleSelect rows: ${rows}`);
if (rows != undefined) {
await rows[0].click();
}
}
export async function doMultiSelect(testNum, selectNum, isSelectOriginal) {
let driver = Driver.create();
await driver.delayMs(1000);
let images = await driver.findComponents(ON.type("Image").clickable(true));
console.info(`${testNum}::doMultiSelect images: ${images}`);
if (images != undefined) {
for (let i = 0; i < images.length; i++) {
if ((i + 1) % 2 == 0 && (i + 1) / 2 <= selectNum) {
await images[i].click();
}
}
await driver.delayMs(1000);
}
if (isSelectOriginal) {
let buttonOrigin = await driver.findComponent(ON.type("Radio"));
console.info(`${testNum}::doMultiSelect buttonOrigin: ${buttonOrigin}`);
if (buttonOrigin != undefined) {
await buttonOrigin.click();
await driver.delayMs(1000);
}
}
let text = await driver.findComponent(ON.text("完成"));
console.info(`${testNum}::doMultiSelect text: ${text}`);
if (text != undefined) {
await text.click();
}
}
export async function doFileSelect(testNum, dirName, fileName) {
let driver = Driver.create();
await driver.delayMs(1000);
let enter = await driver.findComponent(ON.text("com.huawei.hmos.filemanager"));
console.info(`${testNum}::doFileSelect enter: ${enter}`);
if (enter != undefined) {
await enter.click();
await driver.delayMs(1000);
}
let buttonAllow = await driver.findComponent(ON.text("允许"));
console.info(`${testNum}::doFileSelect buttonAllow: ${buttonAllow}`);
if (buttonAllow != undefined) {
await buttonAllow.click();
await driver.delayMs(1000);
}
let row1 = await driver.findComponent(ON.text("文档"));
console.info(`${testNum}::doFileSelect row1: ${row1}`);
if (row1 != undefined) {
await row1.click();
await driver.delayMs(1000);
}
let myPhone = await driver.findComponent(ON.text("我的手机"));
console.info(`${testNum}::doFileSelect myPhone: ${myPhone}`);
if (myPhone != undefined) {
await myPhone.click();
await driver.delayMs(1000);
}
const delegator = abilityDelegatorRegistry.getAbilityDelegator();
let row2 = await driver.findComponent(ON.text(dirName));
console.info(`${testNum}::doFileSelect row2: ${row2}`);
if (row2 != undefined) {
await row2.click();
await driver.delayMs(1000);
}
let asset = await driver.findComponent(ON.text(fileName));
console.info(`${testNum}::doFileSelect asset: ${asset}`);
if (asset != undefined) {
await asset.click();
await driver.delayMs(1000);
}
let button = await driver.findComponent(ON.text("上传"));
if (button != undefined) {
await button.click();
}
}
export async function doSave(testNum, dirName) {
let driver = Driver.create();
await driver.delayMs(1000);
let enter = await driver.findComponent(ON.text("com.huawei.hmos.filemanager"));
console.info(`${testNum}::doSave enter: ${enter}`);
if (enter != undefined) {
await enter.click();
await driver.delayMs(1000);
}
let buttonAllow = await driver.findComponent(ON.text("允许"));
console.info(`${testNum}::doSave buttonAllow: ${buttonAllow}`);
if (buttonAllow != undefined) {
await buttonAllow.click();
await driver.delayMs(1000);
}
let row1 = await driver.findComponent(ON.text("文档"));
console.info(`${testNum}::doSave row1: ${row1}`);
if (row1 != undefined) {
await row1.click();
await driver.delayMs(1000);
}
let myPhone = await driver.findComponent(ON.text("我的手机"));
console.info(`${testNum}::doFileSelect myPhone: ${myPhone}`);
if (myPhone != undefined) {
await myPhone.click();
await driver.delayMs(1000);
}
let row2 = await driver.findComponent(ON.text(dirName));
console.info(`${testNum}::doSave row2: ${row2}`);
if (row2 != undefined) {
await row2.click();
await driver.delayMs(1000);
}
let button = await driver.findComponent(ON.text("保存"));
if (button != undefined) {
await button.click();
}
export async function startAbility(bundleName: string, abilityName: string) {
await delegator.executeShellCommand(`aa start -b ${bundleName} -a ${abilityName}`).then(result => {
console.info(`[picker] start abilityFinished: ${result}`)
}).catch(err => {
console.error(`[picker] start abilityFailed: ${err}`)
})
}
export async function saveAndConcel(testNum) {
let driver = Driver.create();
await driver.delayMs(1000);
let enter = await driver.findComponent(ON.text("com.huawei.hmos.filemanager"));
console.info(`${testNum}::saveAndConcel enter: ${enter}`);
if (enter != undefined) {
await enter.click();
await driver.delayMs(1000);
export async function sleep(times) {
if (!times) {
times = 10;
}
await new Promise((res) => setTimeout(res, times));
};
let buttonAllow = await driver.findComponent(ON.text("允许"));
if (buttonAllow != undefined) {
await buttonAllow.click();
await driver.delayMs(1000);
}
let button = await driver.findComponent(ON.text("取消"));
if (button != undefined) {
await button.click();
}
}
\ No newline at end of file
......@@ -14,11 +14,17 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common"
import { sleep, startAbility } from "./Common"
import picker from '@ohos.file.picker'
export default function audioPickerCallback(abilityContext) {
describe("audioPickerCallback", function () {
afterEach(async function() {
await sleep(500);
await startAbility('ohos.acts.storage.picker', 'com.example.myapplication.MainAbility');
await sleep(500);
})
async function select(testNum, done, dirName, fileName) {
try {
let audioPicker = new picker.AudioViewPicker();
......@@ -33,7 +39,8 @@ export default function audioPickerCallback(abilityContext) {
expect(result.length).assertEqual(1);
done();
});
await doFileSelect(testNum, dirName, fileName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::select error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -55,7 +62,8 @@ export default function audioPickerCallback(abilityContext) {
expect(result.length).assertEqual(1);
done();
});
await doFileSelect(testNum, dirName, fileName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -77,7 +85,8 @@ export default function audioPickerCallback(abilityContext) {
expect(result.length).assertEqual(0);
done();
});
await saveAndConcel(testNum);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -99,7 +108,8 @@ export default function audioPickerCallback(abilityContext) {
expect(result.length).assertEqual(1);
done();
});
await doSave(testNum, dirName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......
......@@ -14,11 +14,17 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common"
import { sleep, startAbility } from "./Common"
import picker from '@ohos.file.picker'
export default function audioPickerPromise(abilityContext) {
describe("audioPickerPromise", function () {
afterEach(async function() {
await sleep(500);
await startAbility('ohos.acts.storage.picker', 'com.example.myapplication.MainAbility');
await sleep(500);
})
async function select(testNum, done, dirName, fileName) {
try {
let audioPicker = new picker.AudioViewPicker();
......@@ -30,8 +36,10 @@ export default function audioPickerPromise(abilityContext) {
console.info(`${testNum}::select err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
return;
})
await doFileSelect(testNum, dirName, fileName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::select error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -50,8 +58,10 @@ export default function audioPickerPromise(abilityContext) {
console.info(`${testNum}::selectWithOption err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
return;
})
await doFileSelect(testNum, dirName, fileName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -70,8 +80,10 @@ export default function audioPickerPromise(abilityContext) {
console.info(`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
return
})
await saveAndConcel(testNum);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -90,8 +102,10 @@ export default function audioPickerPromise(abilityContext) {
console.info(`${testNum}::saveWithOption err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
return;
})
await doSave(testNum, dirName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......
......@@ -13,13 +13,18 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common"
import { sleep, startAbility } from "./Common"
import picker from '@ohos.file.picker'
export default function documentPickerCallback(abilityContext) {
describe("documentPickerCallback", function () {
afterEach(async function() {
await sleep(500);
await startAbility('ohos.acts.storage.picker', 'com.example.myapplication.MainAbility');
await sleep(500);
})
async function select(testNum, done, dirName, fileName) {
try {
let documentPicker = new picker.DocumentViewPicker();
......@@ -34,7 +39,8 @@ export default function documentPickerCallback(abilityContext) {
expect(result.length).assertEqual(1);
done();
});
await doFileSelect(testNum, dirName, fileName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::select error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -56,7 +62,8 @@ export default function documentPickerCallback(abilityContext) {
expect(result.length).assertEqual(1);
done();
});
await doFileSelect(testNum, dirName, fileName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -78,7 +85,8 @@ export default function documentPickerCallback(abilityContext) {
expect(result.length).assertEqual(0);
done();
});
await saveAndConcel(testNum);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -100,7 +108,8 @@ export default function documentPickerCallback(abilityContext) {
expect(result.length).assertEqual(1);
done();
});
await doSave(testNum, dirName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......
......@@ -13,13 +13,18 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common"
import { sleep, startAbility } from "./Common"
import picker from '@ohos.file.picker'
export default function documentPickerPromise(abilityContext) {
describe("documentPickerPromise", function () {
afterEach(async function() {
await sleep(500);
await startAbility('ohos.acts.storage.picker', 'com.example.myapplication.MainAbility');
await sleep(500);
})
async function select(testNum, done, dirName, fileName) {
try {
let documentPicker = new picker.DocumentViewPicker();
......@@ -31,8 +36,10 @@ export default function documentPickerPromise(abilityContext) {
console.info(`${testNum}::select err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
return;
})
await doFileSelect(testNum, dirName, fileName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::select error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -51,8 +58,10 @@ export default function documentPickerPromise(abilityContext) {
console.info(`${testNum}::selectWithOption err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
return;
})
await doFileSelect(testNum, dirName, fileName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -71,8 +80,10 @@ export default function documentPickerPromise(abilityContext) {
console.info(`${testNum}::saveWithoutSelect err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
return;
})
await saveAndConcel(testNum);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -91,8 +102,10 @@ export default function documentPickerPromise(abilityContext) {
console.info(`${testNum}::saveWithOption err: ${JSON.stringify(err)}`);
expect(false).assertTrue();
done();
return;
})
await doSave(testNum, dirName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......
......@@ -14,15 +14,17 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import { getPermission, doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common"
import { sleep, startAbility } from "./Common"
import picker from '@ohos.file.picker'
export default function photoPickerCallback(abilityContext) {
describe("photoPickerCallback", function () {
beforeAll(async function () {
//await getPermission(abilityContext);
});
afterEach(async function() {
await sleep(500);
await startAbility('ohos.acts.storage.picker', 'com.example.myapplication.MainAbility');
await sleep(500);
})
async function select(testNum, done, isSelectOriginal, expectSelectNum = 2) {
try {
let photoPicker = new picker.PhotoViewPicker();
......@@ -38,7 +40,8 @@ export default function photoPickerCallback(abilityContext) {
expect(result.isOriginalPhoto).assertEqual(isSelectOriginal);
done();
});
await doMultiSelect(testNum, expectSelectNum, isSelectOriginal);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::select error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -60,11 +63,8 @@ export default function photoPickerCallback(abilityContext) {
expect(result.photoUris.length).assertEqual(expectSelectNum);
done();
});
if (option.maxSelectNumber != undefined && option.maxSelectNumber == 1) {
await doSingleSelect(testNum);
} else {
await doMultiSelect(testNum, expectSelectNum, false);
}
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -86,7 +86,8 @@ export default function photoPickerCallback(abilityContext) {
expect(result.length).assertEqual(0);
done();
});
await saveAndConcel(testNum);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -108,7 +109,8 @@ export default function photoPickerCallback(abilityContext) {
expect(result != undefined).assertTrue();
done();
});
await doSave(testNum, dirName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......
......@@ -14,11 +14,17 @@
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index";
import { doSingleSelect, doMultiSelect, doFileSelect, doSave, saveAndConcel } from "./Common"
import { sleep, startAbility } from "./Common"
import picker from '@ohos.file.picker'
export default function photoPickerPromise(abilityContext) {
describe("photoPickerPromise", function () {
afterEach(async function() {
await sleep(500);
await startAbility('ohos.acts.storage.picker', 'com.example.myapplication.MainAbility');
await sleep(500);
})
async function select(testNum, done, isSelectOriginal, expectSelectNum = 2) {
try {
let photoPicker = new picker.PhotoViewPicker();
......@@ -31,7 +37,8 @@ export default function photoPickerPromise(abilityContext) {
expect(false).assertTrue();
done();
})
await doMultiSelect(testNum, expectSelectNum, isSelectOriginal);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::select error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -51,11 +58,8 @@ export default function photoPickerPromise(abilityContext) {
expect(false).assertTrue();
done();
})
if (option.maxSelectNumber != undefined && option.maxSelectNumber == 1) {
await doSingleSelect(testNum);
} else {
await doMultiSelect(testNum, expectSelectNum, false);
}
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::selectWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -75,7 +79,8 @@ export default function photoPickerPromise(abilityContext) {
expect(false).assertTrue();
done();
})
await saveAndConcel(testNum);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithoutSelect error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......@@ -95,7 +100,8 @@ export default function photoPickerPromise(abilityContext) {
expect(false).assertTrue();
done();
})
await doSave(testNum, dirName);
expect(true).assertTrue();
done();
} catch (error) {
console.info(`${testNum}::saveWithOption error: ${JSON.stringify(error)}`);
expect(false).assertTrue();
......
......@@ -40,11 +40,6 @@
}
]
}
],
"requestPermissions": [
{
"name": "ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
]
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册