mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 15:10:30 +00:00
commit
3543479d12
@ -29,8 +29,8 @@
|
||||
#include "base/utils/string_expression.h"
|
||||
#include "base/utils/string_utils.h"
|
||||
#include "base/utils/time_util.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "base/utils/utf.h"
|
||||
#include "base/utils/utils.h"
|
||||
|
||||
#ifndef WINDOWS_PLATFORM
|
||||
#include "securec.h"
|
||||
@ -818,7 +818,6 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest042, TestSize.Level1)
|
||||
ASSERT_EQ(StringUtils::EndWith(startWithValue, prefixString), true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @tc.name: BaseUtilsTest043
|
||||
* @tc.desc: utf8 string
|
||||
@ -872,7 +871,7 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest046, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest047, TestSize.Level1)
|
||||
{
|
||||
uint8_t data[2] = {0xC3, 0x81};
|
||||
uint8_t data[2] = { 0xC3, 0x81 };
|
||||
auto result = ConvertMUtf8ToUtf16Pair(data, 2);
|
||||
EXPECT_EQ(result.first, 0xc1);
|
||||
EXPECT_EQ(result.second, 2);
|
||||
@ -885,7 +884,7 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest047, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest048, TestSize.Level1)
|
||||
{
|
||||
uint8_t data[3] = {0xE1, 0x82, 0x81};
|
||||
uint8_t data[3] = { 0xE1, 0x82, 0x81 };
|
||||
auto result = ConvertMUtf8ToUtf16Pair(data, 3);
|
||||
EXPECT_EQ(result.first, 0x1081);
|
||||
EXPECT_EQ(result.second, 3);
|
||||
@ -898,7 +897,7 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest048, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest049, TestSize.Level1)
|
||||
{
|
||||
uint8_t data[4] = {0xF1, 0x80, 0x80, 0x81};
|
||||
uint8_t data[4] = { 0xF1, 0x80, 0x80, 0x81 };
|
||||
auto result = ConvertMUtf8ToUtf16Pair(data, 4);
|
||||
EXPECT_EQ(result.first, 0xD8C0DC01);
|
||||
EXPECT_EQ(result.second, 4);
|
||||
@ -948,7 +947,7 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest052, TestSize.Level1)
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest053, TestSize.Level1)
|
||||
{
|
||||
const uint8_t* emptyInput = nullptr;
|
||||
uint16_t output[10] = {0};
|
||||
uint16_t output[10] = { 0 };
|
||||
size_t result = ConvertRegionUtf8ToUtf16(emptyInput, output, 0, 10, 0);
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -961,7 +960,7 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest053, TestSize.Level1)
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest054, TestSize.Level1)
|
||||
{
|
||||
const uint8_t* input = reinterpret_cast<const uint8_t*>(u8"a");
|
||||
uint16_t output[10] = {0};
|
||||
uint16_t output[10] = { 0 };
|
||||
size_t result = ConvertRegionUtf8ToUtf16(input, output, 1, 10, 0);
|
||||
EXPECT_EQ(result, 1);
|
||||
EXPECT_EQ(output[0], 'a');
|
||||
@ -975,7 +974,7 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest054, TestSize.Level1)
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest055, TestSize.Level1)
|
||||
{
|
||||
const uint8_t* input = reinterpret_cast<const uint8_t*>(u8"Hello, 世界!");
|
||||
uint16_t output[50] = {0};
|
||||
uint16_t output[50] = { 0 };
|
||||
size_t result = ConvertRegionUtf8ToUtf16(input, output, strlen(reinterpret_cast<const char*>(input)), 50, 0);
|
||||
EXPECT_EQ(result, 10);
|
||||
}
|
||||
@ -988,7 +987,7 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest055, TestSize.Level1)
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest056, TestSize.Level1)
|
||||
{
|
||||
const uint8_t* input = reinterpret_cast<const uint8_t*>(u8"XXXX");
|
||||
uint16_t output[10] = {0};
|
||||
uint16_t output[10] = { 0 };
|
||||
size_t result = ConvertRegionUtf8ToUtf16(input, output, 4, 10, 0);
|
||||
EXPECT_EQ(result, 4);
|
||||
}
|
||||
@ -1001,7 +1000,7 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest056, TestSize.Level1)
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest057, TestSize.Level1)
|
||||
{
|
||||
const uint16_t* emptyInput = nullptr;
|
||||
uint8_t output[10] = {0};
|
||||
uint8_t output[10] = { 0 };
|
||||
size_t result = DebuggerConvertRegionUtf16ToUtf8(emptyInput, output, 0, 10, 0);
|
||||
EXPECT_EQ(result, 0);
|
||||
}
|
||||
@ -1013,8 +1012,8 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest057, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest058, TestSize.Level1)
|
||||
{
|
||||
const uint16_t input[] = {0x0061};
|
||||
uint8_t output[10] = {0};
|
||||
const uint16_t input[] = { 0x0061 };
|
||||
uint8_t output[10] = { 0 };
|
||||
size_t result = DebuggerConvertRegionUtf16ToUtf8(input, output, 1, 10, 0);
|
||||
EXPECT_EQ(result, 1);
|
||||
EXPECT_EQ(output[0], 0x61);
|
||||
@ -1027,8 +1026,8 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest058, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest059, TestSize.Level1)
|
||||
{
|
||||
const uint16_t input[] = {0xD800, 0xDC00};
|
||||
uint8_t output[10] = {0};
|
||||
const uint16_t input[] = { 0xD800, 0xDC00 };
|
||||
uint8_t output[10] = { 0 };
|
||||
size_t result = DebuggerConvertRegionUtf16ToUtf8(input, output, 2, 10, 0);
|
||||
EXPECT_EQ(result, 4);
|
||||
}
|
||||
@ -1040,8 +1039,8 @@ HWTEST_F(BaseUtilsTest, BaseUtilsTest059, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(BaseUtilsTest, BaseUtilsTest060, TestSize.Level1)
|
||||
{
|
||||
const uint16_t input[] = {0xD800, 0xD800};
|
||||
uint8_t output[10] = {0};
|
||||
const uint16_t input[] = { 0xD800, 0xD800 };
|
||||
uint8_t output[10] = { 0 };
|
||||
size_t result = DebuggerConvertRegionUtf16ToUtf8(input, output, 2, 10, 0);
|
||||
EXPECT_EQ(result, 6);
|
||||
}
|
||||
@ -1267,4 +1266,52 @@ HWTEST_F(BaseUtilsTest, StringExpressionTest007, TestSize.Level1)
|
||||
std::vector<std::string> ret3 = StringExpression::ConvertDal2Rpn(formula);
|
||||
EXPECT_EQ(ret3.size(), 17);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DateUtilsTest001
|
||||
* @tc.desc: GetMilliSecondsByDateTime
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BaseUtilsTest, DateUtilsTest001, TestSize.Level1)
|
||||
{
|
||||
std::tm dateTime;
|
||||
Date::GetMilliSecondsByDateTime(dateTime);
|
||||
EXPECT_EQ(dateTime.tm_year != 0, true);
|
||||
EXPECT_EQ(dateTime.tm_mday != 0, true);
|
||||
dateTime.tm_mday = 5;
|
||||
Date::GetMilliSecondsByDateTime(dateTime);
|
||||
EXPECT_EQ(dateTime.tm_year != 0, true);
|
||||
EXPECT_EQ(dateTime.tm_mday == 5, true);
|
||||
dateTime.tm_year = 8;
|
||||
Date::GetMilliSecondsByDateTime(dateTime);
|
||||
EXPECT_EQ(dateTime.tm_year == 8, true);
|
||||
EXPECT_EQ(dateTime.tm_mday == 5, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: StringUtilsTest001
|
||||
* @tc.desc: IsAscii
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BaseUtilsTest, StringUtilsTest001, TestSize.Level1)
|
||||
{
|
||||
std::string str = "abcde";
|
||||
bool ret = StringUtils::IsAscii(str);
|
||||
EXPECT_EQ(ret, true);
|
||||
str = "中文";
|
||||
bool ret2 = StringUtils::IsAscii(str);
|
||||
EXPECT_EQ(ret2, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TimeUtilsTest001
|
||||
* @tc.desc: ConvertTimestampToStr
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BaseUtilsTest, TimeUtilsTest001, TestSize.Level1)
|
||||
{
|
||||
int64_t timestamp = 1626211200;
|
||||
std::string ret = ConvertTimestampToStr(timestamp);
|
||||
EXPECT_EQ(ret, "1970-01-20 03:43:31.200");
|
||||
}
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -79,4 +79,67 @@ HWTEST_F(NodeObjectTest, NodeObjectTest001, TestSize.Level1)
|
||||
EXPECT_EQ(nodeObject->GetBool("bool", true), false);
|
||||
EXPECT_EQ(nodeObject->GetBool("", true), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: NodeObjectTest002
|
||||
* @tc.desc: Put(const char* key, size_t value)/GetUInt(const std::string& key, uint32_t defaultVal)
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(NodeObjectTest, NodeObjectTest002, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Create a NodeObject.
|
||||
*/
|
||||
auto nodeObject = NodeObject::Create();
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. Put(const char* key, size_t value)
|
||||
* @tc.expected: step2. Asserting put success.
|
||||
*/
|
||||
const char* key = "key-string";
|
||||
size_t value = 5;
|
||||
bool ret = nodeObject->Put(key, value);
|
||||
EXPECT_EQ(ret, true);
|
||||
|
||||
/**
|
||||
* @tc.steps: step3. GetUInt(const std::string& key, uint32_t defaultVal)
|
||||
* @tc.expected: step3. Asserting success.
|
||||
*/
|
||||
const std::string key2 = "aaaa";
|
||||
uint32_t defaultVal = 0;
|
||||
// key not exist
|
||||
uint32_t ret2 = nodeObject->GetUInt(key2, defaultVal);
|
||||
EXPECT_EQ(ret2, defaultVal);
|
||||
// key exist
|
||||
const char* key3 = "key-temp";
|
||||
nodeObject->Put(key3, 11);
|
||||
uint32_t ret3 = nodeObject->GetUInt(key3, defaultVal);
|
||||
EXPECT_EQ(ret3, 11);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: NodeObjectTest003
|
||||
* @tc.desc: Put(const char* key, const std::unique_ptr<NodeObject>& value)
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(NodeObjectTest, NodeObjectTest003, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. Create a NodeObject.
|
||||
*/
|
||||
auto nodeObject = NodeObject::Create();
|
||||
|
||||
// value is nullptr
|
||||
const std::unique_ptr<NodeObject> value = nullptr;
|
||||
const char* key = nullptr;
|
||||
bool ret = nodeObject->Put(key, value);
|
||||
EXPECT_EQ(ret, false);
|
||||
// value is not nullptr,key is nullptr
|
||||
auto value2 = NodeObject::Create();
|
||||
bool ret2 = nodeObject->Put(key, value2);
|
||||
EXPECT_EQ(ret2, false);
|
||||
const std::unique_ptr<JsonValue> value3 = std::make_unique<JsonValue>();
|
||||
bool ret3 = nodeObject->Put(key, value3);
|
||||
EXPECT_EQ(ret3, false);
|
||||
}
|
||||
} // namespace OHOS::Ace
|
@ -455,4 +455,27 @@ HWTEST_F(DistributedUiTestNg, DistributedUiTestNg010, TestSize.Level1)
|
||||
distributedUI.UpdateUITree(array);
|
||||
EXPECT_NE(distributedUI.status_, DistributedUI::StateMachine::INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: DistributedUiTestNg011
|
||||
* @tc.desc: DistributedUi UpdateUITree
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(DistributedUiTestNg, DistributedUiTestNg011, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. statement distributedUI and SerializeableObjectArray
|
||||
*/
|
||||
DistributedUI distributedUI;
|
||||
distributedUI.ApplyOneUpdate();
|
||||
EXPECT_EQ(distributedUI.pendingUpdates_.size() == 0, true);
|
||||
SerializeableObjectArray array;
|
||||
std::unique_ptr<SerializeableObject> value = std::make_unique<JsonValue>();
|
||||
array.push_back(std::move(value));
|
||||
distributedUI.RestoreUITree(array);
|
||||
distributedUI.UpdateUITree(array);
|
||||
EXPECT_EQ(distributedUI.pendingUpdates_.size() == 1, true);
|
||||
distributedUI.ApplyOneUpdate();
|
||||
EXPECT_EQ(distributedUI.pendingUpdates_.size() == 0, true);
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
@ -18,10 +18,11 @@
|
||||
#include "core/common/asset_manager_impl.h"
|
||||
#undef private
|
||||
#undef protected
|
||||
#include "adapter/ohos/entrance/file_asset_provider_impl.h"
|
||||
#include "mock_asset.h"
|
||||
#include "test/mock/core/common/mock_container.h"
|
||||
|
||||
#include "adapter/ohos/entrance/file_asset_provider_impl.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
@ -206,4 +207,59 @@ HWTEST_F(AssetTest, AssetTest06, TestSize.Level1)
|
||||
auto asset_Result = assetManager->GetAsset(ASSET_TEST);
|
||||
EXPECT_EQ(asset_Result, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AssetTest07
|
||||
* @tc.desc: Test PushFront/PushBack
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AssetTest, AssetTest07, TestSize.Level1)
|
||||
{
|
||||
auto assetManager = AceType::MakeRefPtr<AssetManagerImpl>();
|
||||
auto assetProvider = AceType::MakeRefPtr<MockAssetProvider>();
|
||||
// assetProvider null
|
||||
assetManager->PushFront(nullptr);
|
||||
assetManager->PushBack(nullptr);
|
||||
EXPECT_EQ(assetManager->assetProviders_.size() == 0, true);
|
||||
// assetProvider is not null,IsValid is true
|
||||
EXPECT_CALL(*assetProvider, IsValid()).Times(1).WillOnce(Return(true));
|
||||
assetManager->PushFront(assetProvider);
|
||||
EXPECT_EQ(assetManager->assetProviders_.size() == 1, true);
|
||||
EXPECT_CALL(*assetProvider, IsValid()).Times(1).WillOnce(Return(true));
|
||||
assetManager->PushBack(assetProvider);
|
||||
EXPECT_EQ(assetManager->assetProviders_.size() == 2, true);
|
||||
// assetProvider is not null,IsValid is false
|
||||
EXPECT_CALL(*assetProvider, IsValid()).Times(1).WillOnce(Return(false));
|
||||
assetManager->PushFront(assetProvider);
|
||||
EXPECT_EQ(assetManager->assetProviders_.size() == 2, true);
|
||||
EXPECT_CALL(*assetProvider, IsValid()).Times(1).WillOnce(Return(false));
|
||||
assetManager->PushBack(assetProvider);
|
||||
EXPECT_EQ(assetManager->assetProviders_.size() == 2, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AssetTest08
|
||||
* @tc.desc: Test GetAssetFromI18n
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AssetTest, AssetTest08, TestSize.Level1)
|
||||
{
|
||||
auto assetManager = AceType::MakeRefPtr<AssetManagerImpl>();
|
||||
auto assetProvider = AceType::MakeRefPtr<MockAssetProvider>();
|
||||
// assetProvider is not null,IsValid is true
|
||||
EXPECT_CALL(*assetProvider, IsValid()).Times(1).WillOnce(Return(true));
|
||||
assetManager->PushFront(assetProvider);
|
||||
EXPECT_EQ(assetManager->assetProviders_.size() == 1, true);
|
||||
EXPECT_CALL(*assetProvider, IsValid()).Times(1).WillOnce(Return(true));
|
||||
assetManager->PushBack(assetProvider);
|
||||
EXPECT_EQ(assetManager->assetProviders_.size() == 2, true);
|
||||
// assetName is empty
|
||||
std::string assetName = "";
|
||||
std::vector<RefPtr<Asset>> ret = assetManager->GetAssetFromI18n(assetName);
|
||||
EXPECT_EQ(ret.size() == 0, true);
|
||||
// assetName is not empty
|
||||
assetName = "test";
|
||||
std::vector<RefPtr<Asset>> ret2 = assetManager->GetAssetFromI18n(assetName);
|
||||
EXPECT_EQ(ret2.size() == 0, true);
|
||||
}
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -14,18 +14,18 @@
|
||||
*/
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "interfaces/inner_api/ace/ui_event_observer.h"
|
||||
|
||||
#include "base/log/log.h"
|
||||
#include "base/memory/ace_type.h"
|
||||
#include "base/utils/utils.h"
|
||||
#include "core/common/recorder/event_config.h"
|
||||
#include "core/common/recorder/event_controller.h"
|
||||
#include "core/common/recorder/event_recorder.h"
|
||||
#include "core/common/recorder/event_config.h"
|
||||
#include "core/common/recorder/exposure_processor.h"
|
||||
#include "core/common/recorder/node_data_cache.h"
|
||||
#include "core/components_ng/pattern/stage/page_info.h"
|
||||
#include "core/components_ng/pattern/stage/page_pattern.h"
|
||||
#include "interfaces/inner_api/ace/ui_event_observer.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
@ -154,7 +154,7 @@ HWTEST_F(EventRecorderTest, EventRecorderTest002, TestSize.Level1)
|
||||
Recorder::NodeDataCache::Get().PutBool(pageNode, "btn_Screenshot", true);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_inspect", "inspect", 11);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_xxx", "xxx", true);
|
||||
std::vector<std::string> values = {"a", "b", "c"};
|
||||
std::vector<std::string> values = { "a", "b", "c" };
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "hahaha", "xixi", values);
|
||||
auto nodeValues = std::unordered_map<std::string, std::string>();
|
||||
nodeValues.emplace("btn_TitleExpand", "");
|
||||
@ -214,7 +214,7 @@ HWTEST_F(EventRecorderTest, EventRecorderTest003, TestSize.Level1)
|
||||
Recorder::NodeDataCache::Get().PutBool(pageNode, "btn_Screenshot", true);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_inspect", "inspect", 11);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_xxx", "xxx", true);
|
||||
std::vector<std::string> values = {"a", "b", "c"};
|
||||
std::vector<std::string> values = { "a", "b", "c" };
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "hahaha", "xixi", values);
|
||||
|
||||
/**
|
||||
@ -224,7 +224,7 @@ HWTEST_F(EventRecorderTest, EventRecorderTest003, TestSize.Level1)
|
||||
Recorder::NodeDataCache::Get().OnPageShow("pages/ScrollPage");
|
||||
auto pageNode2 = CreatePageNode("pages/ScrollPage");
|
||||
|
||||
std::vector<std::string> values2 = {"x", "y", "z"};
|
||||
std::vector<std::string> values2 = { "x", "y", "z" };
|
||||
Recorder::NodeDataCache::Get().PutStringArray(pageNode2, "scroll_item_1", values2);
|
||||
auto nodeValues2 = std::unordered_map<std::string, std::string>();
|
||||
nodeValues2.emplace("btn_TitleExpand", "");
|
||||
@ -260,13 +260,13 @@ HWTEST_F(EventRecorderTest, EventRecorderTest004, TestSize.Level1)
|
||||
Recorder::NodeDataCache::Get().PutBool(pageNode, "btn_Screenshot", true);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_inspect", "inspect", 11);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_xxx", "xxx", true);
|
||||
std::vector<std::string> values = {"a", "b", "c"};
|
||||
std::vector<std::string> values = { "a", "b", "c" };
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "hahaha", "xixi", values);
|
||||
|
||||
Recorder::NodeDataCache::Get().OnPageShow("pages/ScrollPage");
|
||||
auto pageNode2 = CreatePageNode("pages/ScrollPage");
|
||||
|
||||
std::vector<std::string> values2 = {"x", "y", "z"};
|
||||
std::vector<std::string> values2 = { "x", "y", "z" };
|
||||
Recorder::NodeDataCache::Get().PutStringArray(pageNode2, "scroll_item_1", values2);
|
||||
|
||||
/**
|
||||
@ -313,13 +313,13 @@ HWTEST_F(EventRecorderTest, EventRecorderTest005, TestSize.Level1)
|
||||
Recorder::NodeDataCache::Get().PutBool(pageNode, "btn_Screenshot", true);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_inspect", "inspect", 11);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_xxx", "xxx", true);
|
||||
std::vector<std::string> values = {"a", "b", "c"};
|
||||
std::vector<std::string> values = { "a", "b", "c" };
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "hahaha", "xixi", values);
|
||||
|
||||
Recorder::NodeDataCache::Get().OnPageShow("pages/ScrollPage");
|
||||
auto pageNode2 = CreatePageNode("pages/ScrollPage");
|
||||
|
||||
std::vector<std::string> values2 = {"x", "y", "z"};
|
||||
std::vector<std::string> values2 = { "x", "y", "z" };
|
||||
Recorder::NodeDataCache::Get().PutStringArray(pageNode2, "scroll_item_1", values2);
|
||||
|
||||
Recorder::NodeDataCache::Get().OnBeforePagePop();
|
||||
@ -370,13 +370,13 @@ HWTEST_F(EventRecorderTest, EventRecorderTest006, TestSize.Level1)
|
||||
Recorder::NodeDataCache::Get().PutBool(pageNode, "btn_Screenshot", true);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_inspect", "inspect", 11);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_xxx", "xxx", true);
|
||||
std::vector<std::string> values = {"a", "b", "c"};
|
||||
std::vector<std::string> values = { "a", "b", "c" };
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "hahaha", "xixi", values);
|
||||
|
||||
Recorder::NodeDataCache::Get().OnPageShow("pages/ScrollPage");
|
||||
auto pageNode2 = CreatePageNode("pages/ScrollPage");
|
||||
|
||||
std::vector<std::string> values2 = {"x", "y", "z"};
|
||||
std::vector<std::string> values2 = { "x", "y", "z" };
|
||||
Recorder::NodeDataCache::Get().PutStringArray(pageNode2, "scroll_item_1", values2);
|
||||
|
||||
Recorder::NodeDataCache::Get().OnBeforePagePop();
|
||||
@ -417,13 +417,13 @@ HWTEST_F(EventRecorderTest, EventRecorderTest007, TestSize.Level1)
|
||||
Recorder::NodeDataCache::Get().PutBool(pageNode, "btn_Screenshot", true);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_inspect", "inspect", 11);
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "btn_xxx", "xxx", true);
|
||||
std::vector<std::string> values = {"a", "b", "c"};
|
||||
std::vector<std::string> values = { "a", "b", "c" };
|
||||
Recorder::NodeDataCache::Get().PutMultiple(pageNode, "hahaha", "xixi", values);
|
||||
|
||||
Recorder::NodeDataCache::Get().OnPageShow("pages/ScrollPage");
|
||||
auto pageNode2 = CreatePageNode("pages/ScrollPage");
|
||||
|
||||
std::vector<std::string> values2 = {"x", "y", "z"};
|
||||
std::vector<std::string> values2 = { "x", "y", "z" };
|
||||
Recorder::NodeDataCache::Get().PutStringArray(pageNode2, "scroll_item_1", values2);
|
||||
|
||||
Recorder::NodeDataCache::Get().OnBeforePagePop();
|
||||
@ -524,4 +524,68 @@ HWTEST_F(EventRecorderTest, EventRecorderTest009, TestSize.Level1)
|
||||
|
||||
Recorder::EventController::Get().Unregister(observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: EventRecorderTest010
|
||||
* @tc.desc: Test ToString MapToString
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(EventRecorderTest, EventRecorderTest010, TestSize.Level1)
|
||||
{
|
||||
Recorder::EventParamsBuilder eventBuilder;
|
||||
std::string ret = eventBuilder.ToString();
|
||||
EXPECT_EQ(ret, "{}");
|
||||
std::string ret2 = eventBuilder.SetEventType(Recorder::EventType::PAGE_SHOW).ToString();
|
||||
EXPECT_EQ(ret2, "{eventType:1, }");
|
||||
const std::shared_ptr<std::unordered_map<std::string, std::string>> input = nullptr;
|
||||
std::string ret3 = Recorder::MapToString(input);
|
||||
EXPECT_EQ(ret3, "");
|
||||
const std::shared_ptr<std::unordered_map<std::string, std::string>> input2 =
|
||||
std::make_shared<std::unordered_map<std::string, std::string>>();
|
||||
input2->emplace("key1", "value1");
|
||||
std::string ret4 = Recorder::MapToString(input2);
|
||||
EXPECT_EQ(ret4, "{key1:value1, }");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: EventRecorderTest011
|
||||
* @tc.desc: Test SetContainerInfo
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(EventRecorderTest, EventRecorderTest011, TestSize.Level1)
|
||||
{
|
||||
// windowName = "$HA_FLOAT_WINDOW$"
|
||||
std::string windowName = "$HA_FLOAT_WINDOW$";
|
||||
int32_t id = 1;
|
||||
bool foreground = true;
|
||||
Recorder::EventRecorder::Get().SetContainerInfo(windowName, id, foreground);
|
||||
EXPECT_EQ(Recorder::EventRecorder::Get().GetContainerId() == -1, true);
|
||||
Recorder::EventRecorder::Get().SetFocusContainerInfo(windowName, id);
|
||||
EXPECT_EQ(Recorder::EventRecorder::Get().GetContainerId() == -1, true);
|
||||
// windowName = "pages/Index",foreground = true
|
||||
windowName = "pages/Index";
|
||||
Recorder::EventRecorder::Get().SetContainerInfo(windowName, id, true);
|
||||
EXPECT_EQ(Recorder::EventRecorder::Get().GetContainerId() == -1, true);
|
||||
Recorder::EventRecorder::Get().SetFocusContainerInfo(windowName, 2);
|
||||
EXPECT_EQ(Recorder::EventRecorder::Get().GetContainerId() == 2, true);
|
||||
// windowName = "pages/Index",foreground = false
|
||||
Recorder::EventRecorder::Get().SetContainerInfo(windowName, id, false);
|
||||
EXPECT_EQ(Recorder::EventRecorder::Get().GetContainerId() == -1, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: EventRecorderTest012
|
||||
* @tc.desc: Test SetDescription/SetNavDst
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(EventRecorderTest, EventRecorderTest012, TestSize.Level1)
|
||||
{
|
||||
Recorder::EventParamsBuilder eventBuilder;
|
||||
std::string desc = "desc";
|
||||
std::shared_ptr<std::unordered_map<std::string, std::string>> ret = eventBuilder.SetDescription(desc).build();
|
||||
EXPECT_EQ(ret->size(), 1);
|
||||
std::string dstName = "dstName";
|
||||
std::shared_ptr<std::unordered_map<std::string, std::string>> ret2 = eventBuilder.SetNavDst(dstName).build();
|
||||
EXPECT_EQ(ret2->size(), 2);
|
||||
}
|
||||
} // namespace OHOS::Ace
|
||||
|
@ -1763,5 +1763,20 @@ HWTEST_F(PipelineContextTestNg, PipelineContextTestNg096, TestSize.Level1)
|
||||
focusManager->SetNeedTriggerScroll(true);
|
||||
context_->PipelineContext::FlushFocusScroll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: PipelineContextTestNg097
|
||||
* @tc.desc: Test the function RegisterTouchEventListener
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(PipelineContextTestNg, PipelineContextTestNg097, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps1: initialize parameters,construct changeInfoListeners_
|
||||
*/
|
||||
std::shared_ptr<ITouchEventCallback> touchEventCallback = nullptr;
|
||||
context_->RegisterTouchEventListener(touchEventCallback);
|
||||
ASSERT_EQ(context_->listenerVector_.size(), 0);
|
||||
}
|
||||
} // namespace NG
|
||||
} // namespace OHOS::Ace
|
||||
|
Loading…
Reference in New Issue
Block a user