提交 068f5e8d 编写于 作者: O openharmony_ci 提交者: Gitee

!1433 L2_master_xts sync

Merge pull request !1433 from quxianfei/cherry-pick-1640423975
......@@ -18,7 +18,6 @@ group("global") {
if (is_standard_system) {
deps = [
"i18n_standard/intljs:intljs_test",
"i18n_standard/zone/src:ActsZoneUtilTest",
"resmgr_standard/resmgrjs:resmgrjs_test",
]
} else {
......
......@@ -448,6 +448,16 @@ describe('intlTest', function () {
expect(datefmt !== null).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0120
* @tc.name format the datetime with en-GB locale
* @tc.desc check the datetime is not null
*/
it('dateTimeFormat_test_0120', 0, function () {
let datefmt = new Intl.DateTimeFormat();
expect(datefmt !== null).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_DATETIME_0200
* @tc.name format the date with zh locale
......@@ -808,6 +818,16 @@ describe('intlTest', function () {
expect(numfmt.format(123456.789)).assertEqual('123,456.789');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_NUMBER_0120
* @tc.name format the number in zh
* @tc.desc check the number in zh
*/
it('formatNumber_test_0120', 0, function () {
let numfmt = new Intl.NumberFormat();
expect(numfmt !== null).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_NUMBER_0200
* @tc.name format the number in zh-u-nu-latn
......@@ -1113,5 +1133,246 @@ describe('intlTest', function () {
expect(numfmt.resolvedOptions().maximumSignificantDigits).assertEqual(10);
expect(numfmt.resolvedOptions().useGrouping).assertTrue();
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2600
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('pluralrules_test_2600', 0, function () {
let pl = new Intl.PluralRules();
let value = pl.select(0);
console.log('pluralrules_test_2600 ' + value);
expect(value).assertEqual('other');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2700
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('pluralrules_test_2700', 0, function () {
let pl = new Intl.PluralRules('zh');
let value = pl.select(0);
console.log('pluralrules_test_2700 ' + value);
expect(value).assertEqual('other');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2800
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('pluralrules_test_2800', 0, function () {
let pl = new Intl.PluralRules('zh', {'type': 'ordinal'});
let value = pl.select(0);
console.log('pluralrules_test_2800 ' + value);
expect(value).assertEqual('other');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_2900
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('pluralrules_test_2900', 0, function () {
let pl = new Intl.PluralRules('zh', {'localeMatcher': 'lookup'});
let value = pl.select(0);
console.log('pluralrules_test_2900 ' + value);
expect(value).assertEqual('other');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3000
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('pluralrules_test_3000', 0, function () {
let pl = new Intl.PluralRules('zh', {'minimumIntegerDigits': 10});
let value = pl.select(0);
console.log('pluralrules_test_3000 ' + value);
expect(value).assertEqual('other');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3100
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('pluralrules_test_3100', 0, function () {
let pl = new Intl.PluralRules('zh', {'minimumFractionDigits': 11});
let value = pl.select(0);
console.log('pluralrules_test_3100 ' + value);
expect(value).assertEqual('other');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3200
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('pluralrules_test_3200', 0, function () {
let pl = new Intl.PluralRules('zh', {'maximumFractionDigits': 'lookup'});
let value = pl.select(0);
console.log('pluralrules_test_3200 ' + value);
expect(value).assertEqual('other');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3300
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('pluralrules_test_3300', 0, function () {
let pl = new Intl.PluralRules('zh', {'minimumSignificantDigits': 10});
let value = pl.select(0);
console.log('pluralrules_test_3300 ' + value);
expect(value).assertEqual('other');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_PLURAL_3400
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('pluralrules_test_3400', 0, function () {
let pl = new Intl.PluralRules('zh', {'maximumSignificantDigits': 11});
let value = pl.select(0);
console.log('pluralrules_test_3400 ' + value);
expect(value).assertEqual('other');
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3500
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_3500', 0, function () {
let coll = new Intl.Collator();
let value = coll.compare('a', 'b');
console.log('collator_test_3500 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3510
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_3510', 0, function () {
let coll = new Intl.Collator();
let value = coll.compare('a', 'a');
console.log('collator_test_3100 ' + value);
expect(value).assertEqual(0);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3520
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_3520', 0, function () {
let coll = new Intl.Collator();
let value = coll.compare('b', 'a');
console.log('collator_test_3200 ' + value);
expect(value).assertEqual(1);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3600
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_3600', 0, function () {
let coll = new Intl.Collator('zh');
let value = coll.compare('a', 'b');
console.log('collator_test_3600 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3700
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_3700', 0, function () {
let coll = new Intl.Collator('zh', {'collation': 'eor'});
let value = coll.compare('a', 'b');
console.log('collator_test_3700 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3800
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_3800', 0, function () {
let coll = new Intl.Collator('zh', {'sensitivity': 'base'});
let value = coll.compare('a', 'b');
console.log('collator_test_3800 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_3900
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_3900', 0, function () {
let coll = new Intl.Collator('zh', {'caseFirst': 'upper'});
let value = coll.compare('a', 'b');
console.log('collator_test_3900 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4000
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_4000', 0, function () {
let coll = new Intl.Collator('zh', {'numeric': true});
let value = coll.compare('a', 'b');
console.log('collator_test_4000 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4100
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_4100', 0, function () {
let coll = new Intl.Collator('zh', {'ignorePunctuation': true});
let value = coll.compare('a', 'b');
console.log('collator_test_4100 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4200
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_4200', 0, function () {
let coll = new Intl.Collator('zh', {'usage': 'sort'});
let value = coll.compare('a', 'b');
console.log('collator_test_4200 ' + value);
expect(value).assertEqual(-1);
})
/* *
* @tc.number SUB_GLOBAL_INTL_JS_COLLATOR_4300
* @tc.name format the number with numberingSystem
* @tc.desc check the number with numberingSystem
*/
it('collator_test_4300', 0, function () {
let coll = new Intl.Collator('zh', {'localeMatcher': 'lookup'});
let value = coll.compare('a', 'b');
console.log('collator_test_4300 ' + value);
expect(value).assertEqual(-1);
})
console.log('*************end IntlTest*************');
})
\ No newline at end of file
# Copyright (C) 2021 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("//test/xts/tools/build/suite.gni")
#SUBSYSTEM_DIR = "//base/global"
module_output_path = "hit/global"
ohos_moduletest_suite("ActsZoneUtilTest") {
module_out_path = module_output_path
sources = [
"//third_party/googletest/googletest/src/gtest-death-test.cc",
"//third_party/googletest/googletest/src/gtest-filepath.cc",
"//third_party/googletest/googletest/src/gtest-port.cc",
"//third_party/googletest/googletest/src/gtest-printers.cc",
"//third_party/googletest/googletest/src/gtest-test-part.cc",
"//third_party/googletest/googletest/src/gtest-typed-test.cc",
"//third_party/googletest/googletest/src/gtest.cc",
"//third_party/googletest/googletest/src/gtest_main.cc",
"//third_party/googletest/googletest/src/hwext/gtest-ext.cc",
"//third_party/googletest/googletest/src/hwext/gtest-filter.cc",
"//third_party/googletest/googletest/src/hwext/gtest-tag.cc",
"//third_party/googletest/googletest/src/hwext/gtest-utils.cc",
"zone_util_test.cpp",
]
remove_configs = [ "//build/config/compiler:no_rtti" ]
cflags_cc = [ "-frtti" ]
include_dirs = [
"//third_party/googletest/googletest/include",
"//third_party/googletest/googletest",
"//base/global/i18n_standard/interfaces/native/innerkits/zone/include",
"//third_party/icu/icu4c/source/common/unicode",
"//third_party/icu/icu4c/source/common",
"//third_party/libphonenumber/cpp/src",
"//third_party/protobuf/src",
"//third_party/protobuf/src/google",
"//third_party/protobuf/src/google/protobuf",
]
deps = [
"//base/global/i18n_standard/frameworks/zone:zone_util",
"//third_party/libphonenumber/cpp:phonenumber_standard",
"//utils/native/base:utils",
]
}
{
"kits": [
{
"push": [
"ActsZoneUtilTest->/data/local/tmp/ActsZoneUtilTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "ActsZoneUtilTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for ActsZoneUtilTest Tests"
}
\ No newline at end of file
/*
* Copyright (C) 2021 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.
*/
#include <gtest/gtest.h>
#include "zone_util_test.h"
#include "zone_util.h"
namespace OHOS {
using namespace std;
using namespace testing;
using namespace testing::ext;
using namespace OHOS::Global::I18n;
class ZoneUtilTest : public testing::Test {};
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_ONEPARAM_0100
* @tc.name the input country code have multiple timezones
* @tc.desc Test GetDefaultZone(country) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZoneTest0100, Function | MediumTest | Level3)
{
string expects[] = { "Antarctica/McMurdo", "America/Argentina/Buenos_Aires", "Australia/Sydney", "America/Noronha",
"America/St_Johns", "Africa/Kinshasa", "America/Santiago", "Asia/Shanghai", "Asia/Nicosia", "Europe/Berlin",
"America/Guayaquil", "Europe/Madrid", "Pacific/Pohnpei", "America/Godthab", "Asia/Jakarta", "Pacific/Tarawa",
"Asia/Almaty", "Pacific/Majuro", "Asia/Ulaanbaatar", "America/Mexico_City", "Asia/Kuala_Lumpur", "Pacific/Auckland",
"Pacific/Tahiti", "Pacific/Port_Moresby", "Asia/Gaza", "Europe/Lisbon", "Europe/Moscow", "Europe/Kiev",
"Pacific/Wake", "America/New_York", "Asia/Tashkent" };
string countries[] = { "AQ", "AR", "AU", "BR", "CA", "CD", "CL", "CN", "CY", "DE", "EC", "ES", "FM", "GL", "ID",
"KI", "KZ", "MH", "MN", "MX", "MY", "NZ", "PF", "PG", "PS", "PT", "RU", "UA", "UM", "US", "UZ" };
int count = size(expects);
ZoneUtil util;
for (int i = 0; i < count; ++i) {
string out = util.GetDefaultZone(countries[i].c_str());
EXPECT_EQ(out, expects[i]);
}
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_ONEPARAM_0200
* @tc.name the input country code have one timezone
* @tc.desc Test GetDefaultZone(country) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZoneTest0200, Function | MediumTest | Level1)
{
string expects[] = { "Asia/Kabul", "Europe/Sarajevo", "Africa/Abidjan", "Africa/Lusaka" };
string countries[] = { "AF", "BA", "CI", "ZM" };
int count = size(expects);
ZoneUtil util;
for (int i = 0; i < count; ++i) {
string out = util.GetDefaultZone(countries[i].c_str());
EXPECT_EQ(out, expects[i]);
}
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_ONEPARAM_0300
* @tc.name the input country code is lowercase style
* @tc.desc Test GetDefaultZone(country) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZoneTest0300, Function | MediumTest | Level3)
{
string expects[] = { "Asia/Shanghai", "America/New_York" };
string countries[] = { "cn", "us" };
int count = size(countries);
ZoneUtil util;
for (int i = 0; i < count; ++i) {
string out = util.GetDefaultZone(countries[i].c_str());
EXPECT_EQ(out, expects[i]);
}
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_ONEPARAM_0400
* @tc.name the input country code not exist
* @tc.desc Test GetDefaultZone(country) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZoneTest0400, Function | MediumTest | Level3)
{
ZoneUtil util;
string out = util.GetDefaultZone("AAA");
EXPECT_EQ(out, "");
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_ONEPARAM_0500
* @tc.name the input country code is number
* @tc.desc Test GetDefaultZone(country) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZoneTest0500, Function | MediumTest | Level3)
{
ZoneUtil util;
string out = util.GetDefaultZone("123");
EXPECT_EQ(out, "");
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_ONEPARAM_0600
* @tc.name the input country code is null
* @tc.desc Test GetDefaultZone(country) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZoneTest0600, Function | MediumTest | Level4)
{
ZoneUtil util;
string out = util.GetDefaultZone("");
EXPECT_EQ(out, "");
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_TWOPARAM_0100
* @tc.name the input country code have multiple timezones,the offerset matches one timezone
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZone2Test0100, Function | MediumTest | Level3)
{
string expects[] = { "Asia/Shanghai", "America/Detroit" };
int32_t offsets[] = { 3600 * 1000 * 8, -3600 * 1000 * 5 };
string countries[] = { "CN", "US" };
int count = size(expects);
ZoneUtil util;
for (int i = 0; i < count; ++i) {
string out = util.GetDefaultZone(countries[i].c_str(), offsets[i]);
EXPECT_EQ(out, expects[i]);
}
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_TWOPARAM_0200
* @tc.name the input country code have multiple timezones,the offerset not matches anyone timezone
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZone2Test0200, Function | MediumTest | Level3)
{
int32_t offsets[] = { 3600 * 1000 * 1, -3600 * 1000 * 1 };
string countries[] = { "CN", "US" };
int count = size(countries);
ZoneUtil util;
for (int i = 0; i < count; ++i) {
string out = util.GetDefaultZone(countries[i].c_str(), offsets[i]);
EXPECT_EQ(out, "");
}
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_TWOPARAM_0300
* @tc.name the input country code have one timezone,the offerset matches it
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZone2Test0300, Function | MediumTest | Level1)
{
ZoneUtil util;
string out = util.GetDefaultZone("AF", 3600 * 1000 * 4.5);
EXPECT_EQ(out, "Asia/Kabul");
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_TWOPARAM_0400
* @tc.name the input country code have one timezone,the offerset not matches it
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZone2Test0400, Function | MediumTest | Level3)
{
ZoneUtil util;
string out = util.GetDefaultZone("AF", 3600 * 1000 * 1);
EXPECT_EQ(out, "");
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_TWOPARAM_0500
* @tc.name the input country code not exist with offset param in getDefaultZone
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZone2Test0500, Function | MediumTest | Level3)
{
ZoneUtil util;
string out = util.GetDefaultZone("AAA", 3600 * 1000 * 8);
EXPECT_EQ(out, "");
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_TWOPARAM_0600
* @tc.name the input country code is number with offset param in getDefaultZone
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZone2Test0600, Function | MediumTest | Level3)
{
ZoneUtil util;
string out = util.GetDefaultZone("123", 3600 * 1000 * 8);
EXPECT_EQ(out, "");
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETDEFAULTZONE_TWOPARAM_0700
* @tc.name the input country code is null with offset param in getDefaultZone
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetDefaultZone2Test0700, Function | MediumTest | Level3)
{
ZoneUtil util;
string out = util.GetDefaultZone("", 3600 * 1000 * 8);
EXPECT_EQ(out, "");
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_TWOPARAM_0100
* @tc.name the input country code have multiple timezones in getZoneList
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneListTest0100, Function | MediumTest | Level3)
{
vector<string> expects = { "Asia/Shanghai", "Asia/Urumqi" };
string country = "CN";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, out);
EXPECT_EQ(expects.size(), out.size());
if (expects.size() == out.size()) {
for (decltype(expects.size()) i = 0; i < expects.size(); ++i) {
EXPECT_EQ(expects[i], out[i]);
}
}
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_TWOPARAM_0200
* @tc.name the input country code have one timezone in getZoneList
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneListTest0200, Function | MediumTest | Level1)
{
vector<string> expects = { "Asia/Kabul" };
string country = "AF";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, out);
EXPECT_EQ(expects.size(), out.size());
if (expects.size() == out.size()) {
for (decltype(expects.size()) i = 0; i < expects.size(); ++i) {
EXPECT_EQ(expects[i], out[i]);
}
}
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_TWOPARAM_0300
* @tc.name the input country code not exist in getZoneList
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneListTest0300, Function | MediumTest | Level3)
{
string country = "AAA";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, out);
size_t expect = 0;
EXPECT_EQ(expect, out.size());
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_TWOPARAM_0400
* @tc.name the input country code is number in getZoneList
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneListTest0400, Function | MediumTest | Level3)
{
string country = "123";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, out);
size_t expect = 0;
EXPECT_EQ(expect, out.size());
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_TWOPARAM_0500
* @tc.name the input country code is null in getZoneList
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneListTest0500, Function | MediumTest | Level3)
{
string country = "";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, out);
size_t expect = 0;
EXPECT_EQ(expect, out.size());
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_THREEPARAM_0100
* @tc.name the input country code have multiple timezones with three params in getZoneList ,the offset matches one
* timezone
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneList2Test0100, Function | MediumTest | Level3)
{
vector<string> expects = { "Asia/Shanghai" };
string country = "CN";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, 3600 * 1000 * 8, out);
EXPECT_EQ(expects.size(), out.size());
if (expects.size() == out.size()) {
for (decltype(expects.size()) i = 0; i < expects.size(); ++i) {
EXPECT_EQ(expects[i], out[i]);
}
}
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_THREEPARAM_0200
* @tc.name the input country code have multiple timezones with three params in getZoneList ,the offset not matches
* anyone timezone
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneList2Test0200, Function | MediumTest | Level3)
{
string country = "CN";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, 3600 * 1000 * 1, out);
size_t expect = 0;
EXPECT_EQ(expect, out.size());
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_THREEPARAM_0300
* @tc.name the input country code have one timezone with three params in getZoneList ,the offset matches
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneList2Test0300, Function | MediumTest | Level3)
{
vector<string> expects = { "Europe/London" };
string country = "GB";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, 3600 * 1000 * 1, out);
// EXPECT_EQ(expects.size(), out.size());
if (expects.size() == out.size()) {
for (decltype(expects.size()) i = 0; i < expects.size(); ++i) {
EXPECT_EQ(expects[i], out[i]);
}
}
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_THREEPARAM_0400
* @tc.name the input country code have one timezone with three params in getZoneList ,the offset not match
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneList2Test0400, Function | MediumTest | Level3)
{
string country = "GB";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, 3600 * 1000 * 5, out);
size_t expect = 0;
EXPECT_EQ(expect, out.size());
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_THREEPARAM_0500
* @tc.name the input country code not exist with three params in getZoneList
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneList2Test0500, Function | MediumTest | Level3)
{
string country = "GGG";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, 3600 * 1000 * 5, out);
size_t expect = 0;
EXPECT_EQ(expect, out.size());
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_THREEPARAM_0600
* @tc.name the input country code is number with three params in getZoneList
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneList2Test0600, Function | MediumTest | Level3)
{
string country = "123";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, 3600 * 1000 * 5, out);
size_t expect = 0;
EXPECT_EQ(expect, out.size());
}
/* *
* @tc.number SUB_GLOBAL_I18N_TIMEZONE_GETZONELIST_THREEPARAM_0700
* @tc.name the input country code is null with three params in getZoneList
* @tc.desc Test GetDefaultZone(country, offset) function.
* @tc.require SR000FK13G
*/
HWTEST_F(ZoneUtilTest, GetZoneList2Test0700, Function | MediumTest | Level3)
{
string country = "";
vector<string> out;
ZoneUtil util;
util.GetZoneList(country, 3600 * 1000 * 5, out);
size_t expect = 0;
EXPECT_EQ(expect, out.size());
}
}
/*
* Copyright (C) 2021 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.
*/
#ifndef OHOS_GLOBAL_I18N_ZONE_UTIL_TEST_H
#define OHOS_GLOBAL_I18N_ZONE_UTIL_TEST_H
int GetDefaultZoneTest0100();
int GetDefaultZoneTest0200();
int GetDefaultZoneTest0300();
int GetDefaultZoneTest0400();
int GetDefaultZoneTest0500();
int GetDefaultZoneTest0600();
int GetDefaultZone2Test0100();
int GetDefaultZone2Test0200();
int GetDefaultZone2Test0300();
int GetDefaultZone2Test0400();
int GetDefaultZone2Test0500();
int GetDefaultZone2Test0600();
int GetDefaultZone2Test0700();
int GetZoneListTest0100();
int GetZoneListTest0200();
int GetZoneListTest0300();
int GetZoneListTest0400();
int GetZoneListTest0500();
int GetZoneList2Test0100();
int GetZoneList2Test0200();
int GetZoneList2Test0300();
int GetZoneList2Test0400();
int GetZoneList2Test0500();
int GetZoneList2Test0600();
int GetZoneList2Test0700();
#endif
......@@ -202,8 +202,8 @@ describe('resMgrTest', function () {
it('getConfiguration_test_002', 0, async function (done) {
resmgr.getResourceManager((error, mgr) => {
mgr.getConfiguration().then(cfg => {
cfg.direction = Direction.DIRECTION_HORIZONTAL;
expect(cfg !== null).assertTrue();
cfg.direction = Direction.DIRECTION_HORIZONTAL;
})
})
done();
......@@ -220,9 +220,9 @@ describe('resMgrTest', function () {
dc.screenDensity = ScreenDensity.SCREEN_SDPI;
dc.deviceType = DeviceType.DEVICE_TYPE_PHONE;
dc.screenDensity = ScreenDensity.SCREEN_MDPI;
dc.deviceType = DeviceType.DEVICE_TYPE_TABLET;
dc.screenDensity = ScreenDensity.SCREEN_LDPI;
dc.deviceType = DeviceType.DEVICE_TYPE_CAR;
dc.screenDensity = ScreenDensity.SCREEN_LDPI;
dc.deviceType = DeviceType.DEVICE_TYPE_TV;
expect(dc !== null).assertTrue();
})
})
......@@ -238,12 +238,12 @@ describe('resMgrTest', function () {
resmgr.getResourceManager((error, mgr) => {
mgr.getDeviceCapability().then(dc => {
dc.screenDensity = ScreenDensity.SCREEN_XLDPI;
dc.deviceType = DeviceType.DEVICE_TYPE_PC;
dc.deviceType = DeviceType.DEVICE_TYPE_TABLET;
dc.screenDensity = ScreenDensity.SCREEN_XXLDPI;
dc.deviceType = DeviceType.DEVICE_TYPE_TV;
dc.screenDensity = ScreenDensity.SCREEN_XXXLDPI;
dc.deviceType = DeviceType.DEVICE_TYPE_WEARABLE;
dc.screenDensity = ScreenDensity.SCREEN_XXXLDPI;
expect(dc !== null).assertTrue();
console.log('getDeviceCapability_test_002 ' + dc);
})
})
done();
......@@ -258,6 +258,7 @@ describe('resMgrTest', function () {
resmgr.getResourceManager((error, mgr) => {
mgr.getPluralString(0x1000003, 1, (error, value) => {
expect(value !== null).assertTrue();
console.log('getPluralString_test_001 ' + value);
})
})
done();
......@@ -272,9 +273,27 @@ describe('resMgrTest', function () {
resmgr.getResourceManager((error, mgr) => {
mgr.getPluralString(0x1000003, 1).then(value => {
expect(value !== null).assertTrue();
console.log('getPluralString_test_002 ' + value);
})
})
done();
})
/* *
* @tc.number SUB_GLOBAL_RESMGR_JS_1900
* @tc.name test getString method in callback mode
* @tc.desc get the string in callback mode
*/
it('getString_test_003', 0, async function (done) {
resmgr.getResourceManager((error, mgr) => {
mgr.getString(0x7000000, (err, value) => {
expect(value !== null).assertTrue();
console.log('getString_test_003 ' + value);
expect(value).assertEqual('hello world!');
})
})
done();
})
console.log('*************end ResmgrTest*************');
})
\ No newline at end of file
# Copyright (C) 2021 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("//build/ohos_var.gni")
group("hdfacttest") {
testonly = true
if (device_name == "rk3568") {
if (is_standard_system) {
deps = [
#"audio:ActsHdfXtstestAudioTest",
"input:ActsHdfXtstestInputTest",
]
}
} else {
if (is_standard_system) {
deps = [
#"audio:ActsHdfXtstestAudioTest",
"input:ActsHdfXtstestInputTest",
"sensor:ActsHdfXtstestSensorTest",
"wlan/wifi:ActsHdfXtstestWifiTest",
]
}
}
}
# Copyright (c) 2021 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("//build/ohos_var.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//test/xts/tools/build/suite.gni")
#################################group#########################################
group("ActsHdfXtstestAudioTest") {
if (!defined(ohos_lite)) {
testonly = true
}
deps = []
deps += [ "hdi:hdi" ]
}
###############################################################################
{
"kits": [
{
"push": [
"ActsHdfXtstestAudioTest->/data/local/tmp/ActsHdfXtstestAudioTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "ActsHdfXtstestAudioTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for ActsHdfXtstestAudioTest Tests"
}
\ No newline at end of file
/**
* Copyright (c) 2021 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.
*/
/**
* @addtogroup Audio
* @{
*
* @brief Defines audio-related APIs, including custom data types and functions for loading drivers,
* accessing a driver adapter, and rendering and capturing audios.
*
* @since 1.0
* @version 1.0
*/
/**
* @file audio_adapter.h
*
* @brief Declares APIs for operations related to the audio adapter.
*
* @since 1.0
* @version 1.0
*/
#ifndef AUDIO_HDI_COMMON_H
#define AUDIO_HDI_COMMON_H
#include <gtest/gtest.h>
#include "audio_adapter.h"
#include "audio_internal.h"
#include "audio_types.h"
#include "hdf_io_service_if.h"
#include "hdf_sbuf.h"
#include "audio_proxy_manager.h"
namespace HMOS {
namespace Audio {
#ifdef AUDIO_ADM_SO
const std::string FUNCTION_NAME = "GetAudioManagerFuncs";
const std::string RESOLVED_PATH = "//system/lib/libhdi_audio.z.so";
using TestAudioManager = struct AudioManager;
const int IS_ADM = true;
#endif
#ifdef AUDIO_MPI_SO
const std::string FUNCTION_NAME = "GetAudioManagerFuncs";
const std::string RESOLVED_PATH = "//system/lib/libhdi_audio.z.so";
using TestAudioManager = struct AudioManager;
const int IS_ADM = false;
#endif
#ifdef AUDIO_ADM_SERVICE
const std::string FUNCTION_NAME = "GetAudioProxyManagerFuncs";
const std::string RESOLVED_PATH = "//system/lib/libaudio_hdi_proxy_server.z.so";
using TestAudioManager = struct AudioProxyManager;
const int IS_ADM = true;
#endif
#ifdef AUDIO_MPI_SERVICE
const std::string FUNCTION_NAME = "GetAudioProxyManagerFuncs";
const std::string RESOLVED_PATH = "//system/lib/libaudio_hdi_proxy_server.z.so";
using TestAudioManager = struct AudioProxyManager;
const int IS_ADM = false;
#endif
#ifdef __LITEOS__
const std::string FUNCTION_NAME = "GetAudioManagerFuncs";
const std::string RESOLVED_PATH = "/usr/lib/libhdi_audio.so";
using TestAudioManager = struct AudioManager;
const int IS_ADM = true;
const std::string AUDIO_FILE = "/userdata/audiorendertest.wav";
const std::string LOW_LATENCY_AUDIO_FILE = "/userdata/lowlatencyrendertest.wav";
const std::string AUDIO_CAPTURE_FILE = "/userdata/audiocapture.wav";
const std::string AUDIO_LOW_LATENCY_CAPTURE_FILE = "/userdata/lowlatencycapturetest.wav";
#else
const std::string AUDIO_FILE = "//bin/audiorendertest.wav";
const std::string LOW_LATENCY_AUDIO_FILE = "//bin/lowlatencyrendertest.wav";
const std::string AUDIO_CAPTURE_FILE = "//bin/audiocapture.wav";
const std::string AUDIO_LOW_LATENCY_CAPTURE_FILE = "//bin/lowlatencycapturetest.wav";
#endif
const std::string AUDIO_RIFF = "RIFF";
const std::string AUDIO_WAVE = "WAVE";
const std::string AUDIO_DATA = "data";
const uint32_t INT_32_MAX = 0x7fffffff;
const uint32_t INDEX_END = 555;
const uint32_t MOVE_RIGHT_NUM = 3;
const int MOVE_LEFT_NUM = 8;
const int CHANNELCOUNT = 2;
const int SAMPLERATE = 48000;
const int DEEP_BUFFER_RENDER_PERIOD_SIZE = 4096;
const float GAIN_MIN = 0;
const float GAIN_MAX = 15;
const uint64_t INITIAL_VALUE = 0;
const int BUFFER_LENTH = 1024 * 16;
const int FILE_CAPTURE_SIZE = 1024 * 1024 * 1;
const uint64_t MEGABYTE = 1024;
const int FRAME_SIZE = 1024;
const int FRAME_COUNT = 4;
const int ADAPTER_COUNT = 32;
const int TRY_NUM_FRAME = 20;
const int AUDIO_ADAPTER_MAX_NUM = 3;
const int64_t SECTONSEC = 1000000000;
const int MICROSECOND = 1000000;
const std::string HDF_CONTROL_SERVICE = "hdf_audio_control";
const std::string HDF_RENDER_SERVICE = "hdf_audio_render";
const std::string HDF_CAPTURE_SERVICE = "hdf_audio_capture";
const int AUDIODRV_CTL_ELEM_IFACE_DAC = 0; /* virtual dac device */
const int AUDIODRV_CTL_ELEM_IFACE_ADC = 1; /* virtual adc device */
const int AUDIODRV_CTL_ELEM_IFACE_GAIN = 2; /* virtual adc device */
const int AUDIODRV_CTL_ELEM_IFACE_MIXER = 3; /* virtual mixer device */
const int AUDIODRV_CTL_ELEM_IFACE_ACODEC = 4; /* Acodec device */
const int AUDIODRV_CTL_ELEM_IFACE_PGA = 5; /* PGA device */
const int AUDIODRV_CTL_ELEM_IFACE_AIAO = 6; /* AIAO device */
enum ControlDispMethodCmd {
AUDIODRV_CTRL_IOCTRL_ELEM_INFO,
AUDIODRV_CTRL_IOCTRL_ELEM_READ,
AUDIODRV_CTRL_IOCTRL_ELEM_WRITE,
AUDIODRV_CTRL_IOCTRL_ELEM_BUTT,
};
enum AudioPCMBit {
PCM_8_BIT = 8,
PCM_16_BIT = 16,
PCM_24_BIT = 24,
PCM_32_BIT = 32,
};
struct AudioCtlElemId {
const char *cardServiceName;
int32_t iface;
const char *itemName; /* ASCII name of item */
};
struct AudioCtlElemValue {
struct AudioCtlElemId id;
int32_t value[2];
};
struct AudioHeadInfo {
uint32_t testFileRiffId;
uint32_t testFileRiffSize;
uint32_t testFileFmt;
uint32_t audioFileFmtId;
uint32_t audioFileFmtSize;
uint16_t audioFileFormat;
uint16_t audioChannelNum;
uint32_t audioSampleRate;
uint32_t audioByteRate;
uint16_t audioBlockAlign;
uint16_t audioBitsPerSample;
uint32_t dataId;
uint32_t dataSize;
};
struct AudioCharacteristic {
bool setmute;
bool getmute;
float setvolume;
float getvolume;
float setgain;
float getgain;
float gainthresholdmin;
float gainthresholdmax;
uint64_t getframes;
uint64_t getframesize;
uint64_t getframecount;
uint32_t getcurrentchannelId;
enum AudioChannelMode setmode;
enum AudioChannelMode getmode;
bool supported;
uint32_t latencyTime;
};
struct PrepareAudioPara {
TestAudioManager *manager;
enum AudioPortDirection portType;
const char *adapterName;
struct AudioAdapter *adapter;
struct AudioPort *audioPort;
void *self;
void *result;
pthread_t tids;
enum AudioPortPin pins;
const char *path;
struct AudioRender *render;
struct AudioCapture *capture;
struct AudioHeadInfo headInfo;
struct AudioAdapterDescriptor *desc;
struct AudioAdapterDescriptor *descs;
char *frame;
uint64_t requestBytes;
uint64_t replyBytes;
uint64_t fileSize;
struct AudioSampleAttributes attrs;
struct AudioCharacteristic character;
struct AudioSampleAttributes attrsValue;
struct AudioSceneDescriptor scenes;
struct AudioPortCapability capability;
enum AudioPortPassthroughMode mode;
struct AudioTimeStamp time;
struct timeval start;
struct timeval end;
long delayTime;
long totalTime;
float averageDelayTime;
struct AudioDeviceDescriptor devDesc;
};
int32_t InitAttrs(struct AudioSampleAttributes &attrs);
int32_t InitDevDesc(struct AudioDeviceDescriptor &devDesc, const uint32_t portId, enum AudioPortPin pins);
int32_t SwitchAdapter(struct AudioAdapterDescriptor *descs, const std::string &adapterNameCase,
enum AudioPortDirection portFlag, struct AudioPort *&audioPort, int size);
uint32_t PcmFormatToBits(enum AudioFormat format);
uint32_t PcmFramesToBytes(const struct AudioSampleAttributes attrs);
int32_t WavHeadAnalysis(struct AudioHeadInfo &wavHeadInfo, FILE *file, struct AudioSampleAttributes &attrs);
int32_t GetAdapters(TestAudioManager *manager, struct AudioAdapterDescriptor **descs, int &size);
int32_t GetLoadAdapter(TestAudioManager *manager, enum AudioPortDirection portType,
const std::string &adapterName, struct AudioAdapter **adapter, struct AudioPort *&audioPort);
int32_t AudioCreateRender(TestAudioManager *manager, enum AudioPortPin pins, const std::string &adapterName,
struct AudioAdapter **adapter, struct AudioRender **render);
int32_t AudioCreateCapture(TestAudioManager *manager, enum AudioPortPin pins, const std::string &adapterName,
struct AudioAdapter **adapter, struct AudioCapture **capture);
int32_t FrameStart(struct AudioHeadInfo wavHeadInfo, struct AudioRender *render, FILE *file,
struct AudioSampleAttributes attrs);
int32_t FrameStartCapture(struct AudioCapture *capture, FILE *file, const struct AudioSampleAttributes attrs);
int32_t RenderFramePrepare(const std::string &path, char *&frame, uint64_t &numRead);
void FrameStatus(int status);
int32_t StartRecord(struct AudioCapture *capture, FILE *file, uint64_t filesize);
int32_t WriteIdToBuf(struct HdfSBuf *sBuf, struct AudioCtlElemId id);
int32_t WriteEleValueToBuf(struct HdfSBuf *sBuf, struct AudioCtlElemValue elemvalue);
int32_t PowerOff(struct AudioCtlElemValue firstElemValue, struct AudioCtlElemValue secondElemValue);
int32_t CheckRegisterStatus(const struct AudioCtlElemId firstId, const struct AudioCtlElemId secondId,
const int firstStatus, const int secondStatus);
int32_t AudioCreateStartRender(TestAudioManager *manager, struct AudioRender **render, struct AudioAdapter **adapter,
const std::string &adapterName);
int32_t AudioRenderStartAndOneFrame(struct AudioRender *render);
int32_t StopAudio(struct PrepareAudioPara &audiopara);
int32_t ThreadRelease(struct PrepareAudioPara &audiopara);
int32_t AudioCreateStartCapture(TestAudioManager *manager, struct AudioCapture **capture,
struct AudioAdapter **adapter, const std::string &adapterName);
int32_t AudioCaptureStartAndOneFrame(struct AudioCapture *capture);
int32_t PlayAudioFile(struct PrepareAudioPara &audiopara);
int32_t RecordAudio(struct PrepareAudioPara &audiopara);
int32_t InitAttrsUpdate(struct AudioSampleAttributes &attrs, enum AudioFormat format, uint32_t channelCount,
uint32_t sampleRate);
int32_t AudioRenderSetGetSampleAttributes(struct AudioSampleAttributes attrs, struct AudioSampleAttributes &attrsValue,
struct AudioRender *render);
int32_t AudioCaptureSetGetSampleAttributes(struct AudioSampleAttributes attrs, struct AudioSampleAttributes &attrsValue,
struct AudioCapture *capture);
int32_t InitMmapDesc(FILE *fp, struct AudioMmapBufferDescripter &desc, int32_t &reqSize, bool flag);
int32_t PlayMapAudioFile(struct PrepareAudioPara &audiopara);
int32_t RecordMapAudio(struct PrepareAudioPara &audiopara);
}
}
#endif // AUDIO_HDI_COMMON_H
# Copyright (c) 2021 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("//build/ohos_var.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/peripheral/audio/audio.gni")
import("//test/xts/tools/build/suite.gni")
###########################end###########################
group("hdi") {
if (!defined(ohos_lite)) {
testonly = true
}
deps = [
"adapter:hdf_audio_hdi_adapter_test",
"capture:hdf_audio_hdi_capture_test",
"render:hdf_audio_hdi_render_test",
]
}
# Copyright (c) 2021 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("//build/ohos_var.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/peripheral/audio/audio.gni")
import("//test/xts/tools/build/suite.gni")
###########################NOT LITEOS##############################
module_output_path = "hdf/audio"
###########################hdf_audio_hdi_adapter_test#####################
ohos_moduletest_suite("hdf_audio_hdi_adapter_test") {
module_out_path = module_output_path
sources = [
"../../common/hdi_common/src/audio_hdi_common.cpp",
"src/audio_hdiadapter_test.cpp",
]
include_dirs = [
"//drivers/peripheral/audio/hal/hdi_passthrough/include",
"//drivers/peripheral/audio/interfaces/include",
"//drivers/peripheral/audio/hal/hdi_binder/proxy/include",
"//drivers/adapter/uhdf2/include/hdi",
"//drivers/adapter/uhdf2/shared/include",
"//drivers/adapter/uhdf2/osal/include",
"//drivers/framework/include/core",
"//drivers/framework/include/utils",
"//drivers/framework/include/osal",
"//drivers/framework/include",
"//drivers/framework/utils/include",
"//third_party/bounds_checking_function/include",
"//drivers/peripheral/audio/test/systemtest/common/hdi_common/include",
"//third_party/googletest/googletest/include/gtest",
"//drivers/peripheral/audio/test/systemtest/hdi/adapter/include",
]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-fsigned-char",
"-fno-common",
"-fno-strict-aliasing",
]
deps = [
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
defines = []
if (enable_audio_adm_so) {
defines += [ "AUDIO_ADM_SO" ]
}
if (enable_audio_mpi_so) {
defines += [ "AUDIO_MPI_SO" ]
}
if (enable_audio_adm_service) {
defines += [ "AUDIO_ADM_SERVICE" ]
}
if (enable_audio_mpi_service) {
defines += [ "AUDIO_MPI_SERVICE" ]
}
}
###########################end###########################
{
"kits": [
{
"push": [
"hdf_audio_hdi_adapter_test->/data/local/tmp/hdf_audio_hdi_adapter_test"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "hdf_audio_hdi_adapter_test",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for hdf_audio_hdi_adapter_test Tests"
}
\ No newline at end of file
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDIADAPTER_TEST_H
#define AUDIO_HDIADAPTER_TEST_H
#endif
# Copyright (c) 2021 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("//build/ohos_var.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/peripheral/audio/audio.gni")
import("//test/xts/tools/build/suite.gni")
###########################systemtest##############################
module_output_path = "hdf/audio"
###########################hdf_audio_hdi_capture_test#####################
ohos_moduletest_suite("hdf_audio_hdi_capture_test") {
module_out_path = module_output_path
sources = [
"../../common/hdi_common/src/audio_hdi_common.cpp",
"src/audio_hdicapture_attr_test.cpp",
"src/audio_hdicapture_control_test.cpp",
"src/audio_hdicapture_scene_test.cpp",
"src/audio_hdicapture_test.cpp",
"src/audio_hdicapture_volume_test.cpp",
]
include_dirs = [
"//drivers/peripheral/audio/hal/hdi_passthrough/include",
"//drivers/peripheral/audio/interfaces/include",
"//drivers/peripheral/audio/hal/hdi_binder/proxy/include",
"//drivers/adapter/uhdf2/include/hdi",
"//drivers/adapter/uhdf2/shared/include",
"//drivers/framework/include/core",
"//drivers/framework/include/utils",
"//drivers/framework/include/osal",
"//drivers/framework/include",
"//third_party/bounds_checking_function/include",
"//drivers/framework/utils/include",
"//drivers/adapter/uhdf2/osal/include",
"//drivers/peripheral/audio/test/systemtest/common/hdi_common/include",
"//third_party/googletest/googletest/include/gtest",
"//drivers/peripheral/audio/test/systemtest/hdi/capture/include",
]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-fsigned-char",
"-fno-common",
"-fno-strict-aliasing",
]
deps = [
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
defines = []
if (enable_audio_adm_so) {
defines += [ "AUDIO_ADM_SO" ]
}
if (enable_audio_mpi_so) {
defines += [ "AUDIO_MPI_SO" ]
}
if (enable_audio_adm_service) {
defines += [ "AUDIO_ADM_SERVICE" ]
}
if (enable_audio_mpi_service) {
defines += [ "AUDIO_MPI_SERVICE" ]
}
}
{
"kits": [
{
"push": [
"hdf_audio_hdi_capture_test->/data/local/tmp/hdf_audio_hdi_capture_test"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "hdf_audio_hdi_capture_test",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for hdf_audio_hdi_capture_test Tests"
}
\ No newline at end of file
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDICAPTURE_ATTR_TEST_H
#define AUDIO_HDICAPTURE_ATTR_TEST_H
#endif
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDICAPTURE_CONTROL_TEST_H
#define AUDIO_HDICAPTURE_CONTROL_TEST_H
#endif
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDICAPTURE_SCENE_TEST_H
#define AUDIO_HDICAPTURE_SCENE_TEST_H
#endif
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDICAPTURE_TEST_H
#define AUDIO_HDICAPTURE_TEST_H
#endif
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDICAPTURE_VOLUME_TEST_H
#define AUDIO_HDICAPTURE_VOLUME_TEST_H
#endif
/*
* Copyright (c) 2021 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.
*/
/**
* @addtogroup Audio
* @{
*
* @brief Defines audio-related APIs, including custom data types and functions for capture drivers function.
* accessing a driver adapter, and capturing audios.
*
* @since 1.0
* @version 1.0
*/
/**
* @file audio_hdi_common.h
*
* @brief Declares APIs for operations related to the capturing audio adapter.
*
* @since 1.0
* @version 1.0
*/
#include "audio_hdi_common.h"
#include "audio_hdicapture_scene_test.h"
using namespace std;
using namespace testing::ext;
using namespace HMOS::Audio;
namespace {
const string ADAPTER_NAME_HDMI = "hdmi";
const string ADAPTER_NAME_USB = "usb";
const string ADAPTER_NAME_INTERNAL = "internal";
class AudioHdiCaptureSceneTest : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
static TestAudioManager *(*GetAudioManager)();
static void *handleSo;
#ifdef AUDIO_MPI_SO
static int32_t (*SdkInit)();
static void (*SdkExit)();
static void *sdkSo;
#endif
int32_t AudioCaptureStart(const string path, struct AudioCapture *capture) const;
};
TestAudioManager *(*AudioHdiCaptureSceneTest::GetAudioManager)() = nullptr;
void *AudioHdiCaptureSceneTest::handleSo = nullptr;
#ifdef AUDIO_MPI_SO
int32_t (*AudioHdiCaptureSceneTest::SdkInit)() = nullptr;
void (*AudioHdiCaptureSceneTest::SdkExit)() = nullptr;
void *AudioHdiCaptureSceneTest::sdkSo = nullptr;
#endif
void AudioHdiCaptureSceneTest::SetUpTestCase(void)
{
#ifdef AUDIO_MPI_SO
char sdkResolvedPath[] = "//system/lib/libhdi_audio_interface_lib_render.z.so";
sdkSo = dlopen(sdkResolvedPath, RTLD_LAZY);
if (sdkSo == nullptr) {
return;
}
SdkInit = (int32_t (*)())(dlsym(sdkSo, "MpiSdkInit"));
if (SdkInit == nullptr) {
return;
}
SdkExit = (void (*)())(dlsym(sdkSo, "MpiSdkExit"));
if (SdkExit == nullptr) {
return;
}
SdkInit();
#endif
char absPath[PATH_MAX] = {0};
if (realpath(RESOLVED_PATH.c_str(), absPath) == nullptr) {
return;
}
handleSo = dlopen(absPath, RTLD_LAZY);
if (handleSo == nullptr) {
return;
}
GetAudioManager = (TestAudioManager *(*)())(dlsym(handleSo, FUNCTION_NAME.c_str()));
if (GetAudioManager == nullptr) {
return;
}
}
void AudioHdiCaptureSceneTest::TearDownTestCase(void)
{
#ifdef AUDIO_MPI_SO
SdkExit();
if (sdkSo != nullptr) {
dlclose(sdkSo);
sdkSo = nullptr;
}
if (SdkInit != nullptr) {
SdkInit = nullptr;
}
if (SdkExit != nullptr) {
SdkExit = nullptr;
}
#endif
if (handleSo != nullptr) {
dlclose(handleSo);
handleSo = nullptr;
}
if (GetAudioManager != nullptr) {
GetAudioManager = nullptr;
}
}
int32_t AudioHdiCaptureSceneTest::AudioCaptureStart(const string path, struct AudioCapture *capture) const
{
int32_t ret = -1;
struct AudioSampleAttributes attrs = {};
ret = InitAttrs(attrs);
if (ret < 0) {
return ret;
}
FILE *file = fopen(path.c_str(), "wb+");
if (file == nullptr) {
return HDF_FAILURE;
}
ret = FrameStartCapture(capture, file, attrs);
(void)fclose(file);
return ret;
}
void AudioHdiCaptureSceneTest::SetUp(void) {}
void AudioHdiCaptureSceneTest::TearDown(void) {}
/**
* @tc.name Test AudioCaptureCheckSceneCapability API and check scene's capability
* @tc.number SUB_Audio_HDI_CaptureCheckSceneCapability_0001
* @tc.desc Test AudioCaptureCheckSceneCapability interface,return 0 if check scene's capability successful.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_CaptureCheckSceneCapability_0001, Function | MediumTest | Level1)
{
int32_t ret = -1;
bool supported = false;
struct AudioSceneDescriptor scenes = {};
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
scenes.scene.id = 0;
scenes.desc.pins = PIN_IN_MIC;
ret = capture->scene.CheckSceneCapability(capture, &scenes, &supported);
EXPECT_EQ(AUDIO_HAL_SUCCESS, ret);
EXPECT_TRUE(supported);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
/**
* @tc.name Test checking scene's capability where the scene is not configured in the json.
* @tc.number SUB_Audio_HDI_CaptureCheckSceneCapability_0002
* @tc.desc Test AudioCreateCapture interface,return -1 if the scene is not configured in the json.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_CaptureCheckSceneCapability_0002, Function | MediumTest | Level1)
{
int32_t ret = -1;
bool supported = true;
struct AudioSceneDescriptor scenes = {};
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
scenes.scene.id = 5;
scenes.desc.pins = PIN_IN_MIC;
ret = capture->scene.CheckSceneCapability(capture, &scenes, &supported);
EXPECT_EQ(AUDIO_HAL_ERR_INTERNAL, ret);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
/**
* @tc.name Test checking scene's capability where the capture is empty
* @tc.number SUB_Audio_HDI_CaptureCheckSceneCapability_0003
* @tc.desc Test AudioCreateCapture interface,return -1 if the capture is empty.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_CaptureCheckSceneCapability_0003, Function | MediumTest | Level1)
{
int32_t ret = -1;
bool supported = true;
struct AudioSceneDescriptor scenes = {};
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
struct AudioCapture *captureNull = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
scenes.scene.id = 0;
scenes.desc.pins = PIN_IN_MIC;
ret = capture->scene.CheckSceneCapability(captureNull, &scenes, &supported);
EXPECT_EQ(AUDIO_HAL_ERR_INVALID_PARAM, ret);
ret = AudioCaptureStart(AUDIO_CAPTURE_FILE, capture);
EXPECT_EQ(AUDIO_HAL_SUCCESS, ret);
capture->control.Stop((AudioHandle)capture);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
/**
* @tc.name Test checking scene's capability where the scene is empty
* @tc.number SUB_Audio_HDI_CaptureCheckSceneCapability_0004
* @tc.desc Test AudioCreateCapture interface,return -1 if the scene is empty.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_CaptureCheckSceneCapability_0004, Function | MediumTest | Level1)
{
int32_t ret = -1;
bool supported = true;
struct AudioSceneDescriptor *scenes = nullptr;
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
ret = capture->scene.CheckSceneCapability(capture, scenes, &supported);
EXPECT_EQ(AUDIO_HAL_ERR_INVALID_PARAM, ret);
ret = AudioCaptureStart(AUDIO_CAPTURE_FILE, capture);
EXPECT_EQ(AUDIO_HAL_SUCCESS, ret);
capture->control.Stop((AudioHandle)capture);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
/**
* @tc.name Test checking scene's capability where the parameter supported is empty.
* @tc.number SUB_Audio_HDI_CaptureCheckSceneCapability_0005
* @tc.desc Test AudioCreateCapture interface,return -1 if the parameter supported is empty.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_CaptureCheckSceneCapability_0005, Function | MediumTest | Level1)
{
int32_t ret = -1;
struct AudioSceneDescriptor scenes = {};
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
scenes.scene.id = 0;
scenes.desc.pins = PIN_IN_MIC;
ret = capture->scene.CheckSceneCapability(capture, &scenes, nullptr);
EXPECT_EQ(AUDIO_HAL_ERR_INVALID_PARAM, ret);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
/**
* @tc.name Test AudioCaptureSelectScene API via legal input
* @tc.number SUB_Audio_HDI_AudioCaptureSelectScene_0001
* @tc.desc Test AudioCaptureSelectScene interface,return 0 if select capture's scene successful.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_AudioCaptureSelectScene_0001, Function | MediumTest | Level1)
{
int32_t ret = -1;
struct AudioSceneDescriptor scenes = {};
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
scenes.scene.id = 0;
scenes.desc.pins = PIN_IN_MIC;
ret = capture->scene.SelectScene(capture, &scenes);
EXPECT_EQ(AUDIO_HAL_SUCCESS, ret);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
/**
* @tc.name Test AudioCaptureSelectScene API after capture start.
* @tc.number SUB_Audio_HDI_AudioCaptureSelectScene_0002
* @tc.desc Test AudioCaptureSelectScene, return 0 if select capture's scene successful after capture start.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_AudioCaptureSelectScene_0002, Function | MediumTest | Level1)
{
int32_t ret = -1;
struct AudioSceneDescriptor scenes = {};
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
ret = AudioCaptureStart(AUDIO_CAPTURE_FILE, capture);
EXPECT_EQ(AUDIO_HAL_SUCCESS, ret);
scenes.scene.id = 0;
scenes.desc.pins = PIN_IN_MIC;
ret = capture->scene.SelectScene(capture, &scenes);
EXPECT_EQ(AUDIO_HAL_SUCCESS, ret);
capture->control.Stop((AudioHandle)capture);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
/**
* @tc.name Test AudioCaptureSelectScene API where the parameter handle is empty.
* @tc.number SUB_Audio_HDI_AudioCaptureSelectScene_0003
* @tc.desc Test AudioCaptureSelectScene, return -1 if the parameter handle is empty.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_AudioCaptureSelectScene_0003, Function | MediumTest | Level1)
{
int32_t ret = -1;
struct AudioSceneDescriptor scenes = {};
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
struct AudioCapture *captureNull = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
scenes.scene.id = 0;
scenes.desc.pins = PIN_IN_MIC;
ret = capture->scene.SelectScene(captureNull, &scenes);
EXPECT_EQ(AUDIO_HAL_ERR_INVALID_PARAM, ret);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
/**
* @tc.name Test AudioCaptureSelectScene API where the parameter scene is empty.
* @tc.number SUB_Audio_HDI_AudioCaptureSelectScene_0004
* @tc.desc Test AudioCaptureSelectScene, return -1 if the parameter scene is empty.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_AudioCaptureSelectScene_0004, Function | MediumTest | Level1)
{
int32_t ret = -1;
struct AudioSceneDescriptor *scenes = nullptr;
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
ret = capture->scene.SelectScene(capture, scenes);
EXPECT_EQ(AUDIO_HAL_ERR_INVALID_PARAM, ret);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
/**
* @tc.name Test AudioCaptureSelectScene API where the scene is not configured in the json.
* @tc.number SUB_Audio_HDI_AudioCaptureSelectScene_0005
* @tc.desc Test AudioCaptureSelectScene, return -1 if the scene is not configured in the json.
*/
HWTEST_F(AudioHdiCaptureSceneTest, SUB_Audio_HDI_AudioCaptureSelectScene_0005, Function | MediumTest | Level1)
{
int32_t ret = -1;
struct AudioSceneDescriptor scenes = {};
struct AudioAdapter *adapter = nullptr;
struct AudioCapture *capture = nullptr;
ASSERT_NE(nullptr, GetAudioManager);
TestAudioManager* manager = GetAudioManager();
ret = AudioCreateCapture(manager, PIN_IN_MIC, ADAPTER_NAME_INTERNAL, &adapter, &capture);
ASSERT_EQ(AUDIO_HAL_SUCCESS, ret);
scenes.scene.id = 5;
scenes.desc.pins = PIN_OUT_HDMI;
ret = capture->scene.SelectScene(capture, &scenes);
EXPECT_EQ(AUDIO_HAL_ERR_INTERNAL, ret);
adapter->DestroyCapture(adapter, capture);
manager->UnloadAdapter(manager, adapter);
}
}
\ No newline at end of file
# Copyright (c) 2021 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("//build/ohos_var.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//drivers/peripheral/audio/audio.gni")
import("//test/xts/tools/build/suite.gni")
###########################systemtest##############################
module_output_path = "hdf/audio"
###########################hdf_audio_hdi_render_test######################
ohos_moduletest_suite("hdf_audio_hdi_render_test") {
module_out_path = module_output_path
sources = [
"../../common/hdi_common/src/audio_hdi_common.cpp",
"src/audio_hdirender_attr_test.cpp",
"src/audio_hdirender_control_test.cpp",
"src/audio_hdirender_scene_test.cpp",
"src/audio_hdirender_test.cpp",
"src/audio_hdirender_volume_test.cpp",
]
include_dirs = [
"//drivers/peripheral/audio/hal/hdi_passthrough/include",
"//drivers/peripheral/audio/interfaces/include",
"//drivers/peripheral/audio/hal/hdi_binder/proxy/include",
"//drivers/adapter/uhdf2/include/hdi",
"//drivers/adapter/uhdf2/shared/include",
"//drivers/framework/include/core",
"//drivers/framework/include/utils",
"//drivers/framework/include/osal",
"//drivers/framework/include",
"//third_party/bounds_checking_function/include",
"//drivers/framework/utils/include",
"//drivers/adapter/uhdf2/osal/include",
"//drivers/peripheral/audio/test/systemtest/common/hdi_common/include",
"//third_party/googletest/googletest/include/gtest",
"//drivers/peripheral/audio/test/systemtest/hdi/render/include",
]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-fsigned-char",
"-fno-common",
"-fno-strict-aliasing",
]
deps = [
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
defines = []
if (enable_audio_adm_so) {
defines += [ "AUDIO_ADM_SO" ]
}
if (enable_audio_mpi_so) {
defines += [ "AUDIO_MPI_SO" ]
}
if (enable_audio_adm_service) {
defines += [ "AUDIO_ADM_SERVICE" ]
}
if (enable_audio_mpi_service) {
defines += [ "AUDIO_MPI_SERVICE" ]
}
}
{
"kits": [
{
"push": [
"hdf_audio_hdi_render_test->/data/local/tmp/hdf_audio_hdi_render_test"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "hdf_audio_hdi_render_test",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for hdf_audio_hdi_render_test Tests"
}
\ No newline at end of file
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDIRENDER_ATTR_TEST
#define AUDIO_HDIRENDER_ATTR_TEST
#endif
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDIRENDER_CONTROL_TEST_H
#define AUDIO_HDIRENDER_CONTROL_TEST_H
#endif
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDIRENDER_SCENE_TEST_H
#define AUDIO_HDIRENDER_SCENE_TEST_H
#endif
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDIRENDER_TEST_H
#define AUDIO_HDIRENDER_TEST_H
#endif
/*
* Copyright (c) 2021 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.
*/
#ifndef AUDIO_HDIRENDER_VOLUME_TEST_H
#define AUDIO_HDIRENDER_VOLUME_TEST_H
#endif
# Copyright (c) 2021 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("//build/ohos_var.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "hdf/input"
ohos_moduletest_suite("ActsHdfXtstestInputTest") {
module_out_path = module_output_path
include_dirs = [
"//drivers/framework/test/unittest/include",
"//drivers/peripheral/input/hal/include",
"//drivers/peripheral/input/interfaces/include",
]
sources = [ "./common/hdi_input_test.cpp" ]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-fsigned-char",
"-fno-common",
"-fno-strict-aliasing",
]
deps = [
"$hdf_uhdf_path/test/unittest/common:libhdf_test_common",
"$hdf_uhdf_path/utils:libhdf_utils",
"//drivers/peripheral/input/hal:hdi_input",
"//utils/native/base:utils",
]
if (is_standard_system) {
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
} else {
external_deps = [ "hilog:libhilog" ]
}
}
{
"kits": [
{
"push": [
"ActsHdfXtstestInputTest->/data/local/tmp/ActsHdfXtstestInputTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "ActsHdfXtstestInputTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for ActsHdfXtstestInputTest Tests"
}
\ No newline at end of file
此差异已折叠。
# Copyright (c) 2021 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("//build/ohos_var.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "hdf/sensor"
ohos_moduletest_suite("ActsHdfXtstestSensorTest") {
module_out_path = module_output_path
include_dirs = []
sources = [ "./common/hdf_sensor_test.cpp" ]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-fsigned-char",
"-fno-common",
"-fno-strict-aliasing",
]
deps = [
"$hdf_uhdf_path/utils:libhdf_utils",
"//drivers/peripheral/sensor/hal:hdi_sensor",
"//utils/native/base:utils",
]
if (is_standard_system) {
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
} else {
external_deps = [ "hilog:libhilog" ]
}
}
{
"kits": [
{
"push": [
"ActsHdfXtstestSensorTest->/data/local/tmp/ActsHdfXtstestSensorTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "ActsHdfXtstestSensorTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for ActsHdfXtstestSensorTest Tests"
}
\ No newline at end of file
此差异已折叠。
# Copyright (c) 2021 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("//build/ohos_var.gni")
import("//drivers/adapter/uhdf2/uhdf.gni")
import("//test/xts/tools/build/suite.gni")
module_output_path = "hdf/wlan"
ohos_moduletest_suite("ActsHdfXtstestWifiTest") {
module_out_path = module_output_path
include_dirs = [
"//drivers/framework/test/unittest/include",
"//drivers/peripheral/wlan/client/include",
"//drivers/peripheral/wlan/hal/include",
"//drivers/peripheral/wlan/interfaces/include",
]
sources = [ "./common/wifi_hal_test.cpp" ]
cflags = [
"-Wall",
"-Wextra",
"-Werror",
"-fsigned-char",
"-fno-common",
"-fno-strict-aliasing",
]
deps = [
"$hdf_uhdf_path/test/unittest/common:libhdf_test_common",
"$hdf_uhdf_path/utils:libhdf_utils",
"//drivers/peripheral/wlan/client:wifi_driver_client",
"//drivers/peripheral/wlan/hal:wifi_hal",
"//utils/native/base:utils",
]
if (is_standard_system) {
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
} else {
external_deps = [ "hilog:libhilog" ]
}
}
{
"kits": [
{
"push": [
"ActsHdfXtstestWifiTest->/data/local/tmp/ActsHdfXtstestWifiTest"
],
"type": "PushKit"
}
],
"driver": {
"native-test-timeout": "120000",
"type": "CppTest",
"module-name": "ActsHdfXtstestWifiTest",
"runtime-hint": "1s",
"native-test-device-path": "/data/local/tmp"
},
"description": "Configuration for ActsHdfXtstestWifiTest Tests"
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
......@@ -14,14 +14,6 @@ import("//build/ohos_var.gni")
group("hiviewdfxtestacts") {
testonly = true
if (is_standard_system) {
deps = [
"faultloggertest/faultloggercpptest:ActsFaultLoggerTest",
"hiappeventtest/hiappeventjstest:ActsHiAppEventJsTest",
"hicollietest/hicolliecpptest:ActsHiCollieCppTest",
"hilogtest/libhilogtest:libhilogtestacts",
"hisyseventtest/hisyseventcpptest:ActsHiSysEventCPPTest",
"hitracetest/hitracecpptest:ActsHitraceCPPTest",
"hitracetest/hitracectest:ActsHitraceCTest",
]
deps = [ "hiappeventtest/hiappeventjstest:ActsHiAppEventJsTest" ]
}
}
# Copyright (C) 2021 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("//test/xts/tools/build/suite.gni")
module_output_path = "hits/faultloggertest"
###############################################################################
config("faultloggertest_config") {
visibility = [ ":*" ]
include_dirs = [
"../../utils/native",
"//utils/native/base/include/",
"//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
"genfault.h",
]
}
ohos_moduletest_suite("ActsFaultLoggerTest") {
module_out_path = module_output_path
sources = [
"faultloggertest.cpp",
"genfault.cpp",
]
deps = [
"../../utils/native:utilskit",
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
"//third_party/googletest:gtest_main",
"//utils/native/base:utils",
]
configs = [ ":faultloggertest_config" ]
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册