ProfileAbnormalTestPromise.test.js 14.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright (C) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * You may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * Distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * Limitations under the License.
 */

import media from '@ohos.multimedia.media'
import * as base from './ProfileTestBase.js';
J
jiyong_sd 已提交
18
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
19

J
jiyong_sd 已提交
20
export default function ProfileAbnormalTestPromise() {
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
describe('ProfileAbnormalTestPromise', function () {
    beforeAll(function () {
        console.info('beforeAll case');
    })

    beforeEach(async function () {
        console.info('beforeEach case');
    })

    afterEach(function () {
        console.info('afterEach case');
    })

    afterAll(function () {
        console.info('afterAll case');
    })

    async function promiseAbnormalGetVideoProfile(sourceId, qualityLevel, done) {
        media.getMediaCapability().then(async (mediaCaps) => {
            console.info('getMediaCapability success');
            if (typeof (mediaCaps) != 'undefined') {
                mediaCaps.getVideoRecorderProfile(sourceId, qualityLevel).then(async (videoCapsArray) => {
                    base.checkVideoCapsArray(videoCapsArray);
                    console.info('getVideoRecorderProfile success');
                    done();
                }, err => {
                    expect(err).assertUndefined();
                    done();
                })
            } else {
                console.info('mediaCaps is undefined');
                expect().assertFail();
                done();
            }
        }, err => {
            expect(err).assertUndefined();
            done();
        })
    }
    
    async function promiseAbnormalAudioRecoderConfigSupported(audioProfile, done) {
        media.getMediaCapability().then(async (mediaCaps) => {
            if (typeof (mediaCaps) != 'undefined') {
                mediaCaps.isAudioRecoderConfigSupported(audioProfile).then(async (ean) => {
                    console.info('isAudioRecoderConfigSupported: success' + ean);
                    expect(ean).assertEqual(false);
                    console.info('isAudioRecoderConfigSupported: success');
                    done();
                }, err => {
                    expect(err).assertUndefined();
                    done();
                })
            } else {
                console.info('mediaCaps is undefined');
                expect().assertFail();
                done();
            }
        }, err => {
            expect(err).assertUndefined();
            done();
        })
    }
    
    async function promiseAbnormalHasVideoProfile(sourceId, qualityLevel, done) {
        media.getMediaCapability().then(async (mediaCaps) => {
            console.info('getMediaCapability success');
            if (typeof (mediaCaps) != 'undefined') {
                mediaCaps.hasVideoRecorderProfile(sourceId, qualityLevel).then(async (ean) => {
                    expect(ean).assertEqual(false);
                    console.info('hasVideoRecorderProfile success');
                    done();
                }, err => {
                    expect(err).assertUndefined();
                    done();
                })
            } else {
                console.info('mediaCaps is undefined');
                expect().assertFail();
                done();
            }
        }, err => {
            expect(err).assertUndefined();
            done();
        })
    }


    /* *
109
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0100
110 111 112 113 114 115
        * @tc.name      : test isAudioRecoderConfigSupported false
        * @tc.desc      : 5 args all set wrong
        * @tc.size      : MediumTest
        * @tc.type      : Function test
        * @tc.level     : Level2
    */
116
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0100', 0, async function (done) {
117 118 119 120 121
        console.info("test getAudioRecorderCaps");
        promiseAbnormalAudioRecoderConfigSupported(base.audioRecorderAbnormalAll, done);
    })

    /* *
122
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0200
123 124 125 126 127 128
        * @tc.name      : test isAudioRecoderConfigSupported false
        * @tc.desc      : FormatType  is wrong
        * @tc.size      : MediumTest
        * @tc.type      : Function test
        * @tc.level     : Level2
    */
129
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0200', 0, async function (done) {
130 131 132 133 134
        console.info("test getAudioRecorderCaps");
        promiseAbnormalAudioRecoderConfigSupported(base.audioRecorderAbnormalFormatType, done);
    })

    /* *
135
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0300
136 137 138 139 140 141
        * @tc.name      : test isAudioRecoderConfigSupported
        * @tc.desc      : CodecMimeType is wrong
        * @tc.size      : MediumTest
        * @tc.type      : Function test
        * @tc.level     : Level2
    */
142
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0300', 0, async function (done) {
143 144 145 146 147
        console.info("test getAudioRecorderCaps");
        promiseAbnormalAudioRecoderConfigSupported(base.audioRecorderAbnormalCodecMimeType, done);
    })

    /* *
148
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0400
149 150 151 152 153 154
        * @tc.name      : test isAudioRecoderConfigSupported
        * @tc.desc      : bitrate is wrong
        * @tc.size      : MediumTest
        * @tc.type      : Function test
        * @tc.level     : Level2
    */
155
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0400', 0, async function (done) {
156 157 158 159 160
        console.info("test getAudioRecorderCaps");
        promiseAbnormalAudioRecoderConfigSupported(base.audioRecorderAbnormalBitrate, done);
    })

    /* *
161
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0500
162 163 164 165 166 167
        * @tc.name      : test isAudioRecoderConfigSupported
        * @tc.desc      : sampleRate is wrong
        * @tc.size      : MediumTest
        * @tc.type      : Function test
        * @tc.level     : Level2
    */
168
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0500', 0, async function (done) {
169 170 171 172 173
        console.info("test getAudioRecorderCaps");
        promiseAbnormalAudioRecoderConfigSupported(base.audioRecorderAbnormalSampleRate, done);
    })

    /* *
174
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0600
175 176 177 178 179 180
        * @tc.name      : test isAudioRecoderConfigSupported
        * @tc.desc      : channel is wrong
        * @tc.size      : MediumTest
        * @tc.type      : Function test
        * @tc.level     : Level2
    */
181
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0600', 0, async function (done) {
182 183 184 185 186
        console.info("test getAudioRecorderCaps");
        promiseAbnormalAudioRecoderConfigSupported(base.audioRecorderAbnormalSampleChannel, done);
    })

    /* *
187
        * @tc.number  : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0700
188 189 190 191 192 193
        * @tc.name    : test hasVideoRecorderProfile
        * @tc.desc    : sourceId 1 qualityLevel 0
        * @tc.size    : MediumTest
        * @tc.type    : Function test
        * @tc.level   : Level2
    */
194
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0700', 0, async function (done) {
195 196 197 198 199
        console.info('test hasVideoRecorderProfile');
        promiseAbnormalHasVideoProfile(1, media.VideoRecorderQualityLevel.RECORDER_QUALITY_LOW, done);
    })

    /* *
200
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0800
201 202 203 204 205 206
        * @tc.name      : test hasVideoRecorderProfile sourceId -1
        * @tc.desc      : sourceId -1 qualityLevel 0
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
207
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0800', 0, async function (done) {
208 209 210 211 212
        console.info("test hasVideoRecorderProfile");
        promiseAbnormalHasVideoProfile(-1, media.VideoRecorderQualityLevel.RECORDER_QUALITY_LOW, done);
    })

    /* *
213
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0900
214 215 216 217 218 219
        * @tc.name      : test hasVideoRecorderProfile qualityLevel -1
        * @tc.desc      : sourceId 0 qualityLevel -1
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
220
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_0900', 0, async function (done) {
221 222 223 224 225
        console.info("test hasVideoRecorderProfile");
        promiseAbnormalHasVideoProfile(0, -1, done);
    })

    /* *
226
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1000
227 228 229 230 231 232
        * @tc.name      : test hasVideoRecorderProfile sourceId 65536
        * @tc.desc      : sourceId 65535 qualityLevel 0
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
233
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1000', 0, async function (done) {
234 235 236 237 238
        console.info("test hasVideoRecorderProfile");
        promiseAbnormalHasVideoProfile(65535, media.VideoRecorderQualityLevel.RECORDER_QUALITY_LOW, done);
    })

    /* *
239
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1100
240 241 242 243 244 245
        * @tc.name      : test hasVideoRecorderProfile sourceId 65536
        * @tc.desc      : sourceId 65536 qualityLevel 0
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
246
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1100', 0, async function (done) {
247 248 249 250 251
        console.info("test hasVideoRecorderProfile");
        promiseAbnormalHasVideoProfile(65536, media.VideoRecorderQualityLevel.RECORDER_QUALITY_LOW, done);
    })

    /* *
252
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1200
253 254 255 256 257 258
        * @tc.name      : test hasVideoRecorderProfile qualityLevel 65536
        * @tc.desc      : sourceId 0 qualityLevel 65535
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
259
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1200', 0, async function (done) {
260 261 262 263 264
        console.info("test hasVideoRecorderProfile");
        promiseAbnormalHasVideoProfile(0, 65535, done);
    })

    /* *
265
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1300
266 267 268 269 270 271
        * @tc.name      : test hasVideoRecorderProfile qualityLevel 65536
        * @tc.desc      : sourceId 0 qualityLevel 65536
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
272
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1300', 0, async function (done) {
273 274 275 276 277
        console.info("test hasVideoRecorderProfile");
        promiseAbnormalHasVideoProfile(0, 65536, done);
    })

    /* *
278
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1400
279 280 281 282 283 284
        * @tc.name      : test getVideoRecorderProfile sourceId -1
        * @tc.desc      : sourceId -1 qualityLevel 0
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
285
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1400', 0, async function (done) {
286 287 288 289 290
        console.info("test getVideoRecorderProfile");
        promiseAbnormalGetVideoProfile(-1, media.VideoRecorderQualityLevel.RECORDER_QUALITY_LOW, done);
    })

    /* *
291
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1500
292 293 294 295 296 297
        * @tc.name      : test getVideoRecorderProfile qualityLevel -1
        * @tc.desc      : sourceId 0 qualityLevel -1
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
298
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1500', 0, async function (done) {
299 300 301 302 303
        console.info("test getVideoRecorderProfile");
        promiseAbnormalGetVideoProfile(0, -1, done);
    })

    /* *
304
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1600
305 306 307 308 309 310
        * @tc.name      : test getVideoRecorderProfile sourceId 65535
        * @tc.desc      : sourceId 65535 qualityLevel 0
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
311
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1600', 0, async function (done) {
312 313 314 315 316
        console.info("test getVideoRecorderProfile");
        promiseAbnormalGetVideoProfile(65535, media.VideoRecorderQualityLevel.RECORDER_QUALITY_LOW, done);
    })

    /* *
317
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1700
318 319 320 321 322 323
        * @tc.name      : test getVideoRecorderProfile sourceId 65536
        * @tc.desc      : sourceId 65536 qualityLevel 0
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
324
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1700', 0, async function (done) {
325 326 327 328 329
        console.info("test getVideoRecorderProfile");
        promiseAbnormalGetVideoProfile(65536, media.VideoRecorderQualityLevel.RECORDER_QUALITY_LOW, done);
    })

    /* *
330
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1800
331 332 333 334 335 336
        * @tc.name      : test getVideoRecorderProfile qualityLevel 65535
        * @tc.desc      : sourceId 0 qualityLevel 65535
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
337
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1800', 0, async function (done) {
338 339 340 341 342
        console.info("test getVideoRecorderProfile");
        promiseAbnormalGetVideoProfile(0, 65535, done);
    })

    /* *
343
        * @tc.number    : SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1900
344 345 346 347 348 349
        * @tc.name      : test getVideoRecorderProfile qualityLevel 65536
        * @tc.desc      : sourceId 0 qualityLevel 65536
        * @tc.size      : MediumTest
        * @tc.type      : Abnormal test
        * @tc.level     : Level2
    */
350
    it('SUB_MULTIMEDIA_MEDIA_PROFILE_RELIABILITY_PROMISE_1900', 0, async function (done) {
351 352 353 354
        console.info("test getVideoRecorderProfile");
        promiseAbnormalGetVideoProfile(0, 65536, done);
    })
})
J
jiyong_sd 已提交
355
}