mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-27 09:12:41 +00:00
Record exposure event by config.
Signed-off-by: wudi <wudi24@huawei.com> Change-Id: Ief3235b6a503e871c2d2712aa727899e3f42cbcb
This commit is contained in:
parent
48f2cb5624
commit
87778d5f44
@ -22,6 +22,11 @@
|
||||
#include "core/common/recorder/event_config.h"
|
||||
|
||||
namespace OHOS::Ace::Recorder {
|
||||
constexpr char ORIGIN_PARAM[] = "$origin";
|
||||
constexpr char EXPOSURE_CONFIG_PARAM[] = "$exposureCfg";
|
||||
constexpr char EXPOSURE_CONFIG_RATIO[] = "ratio";
|
||||
constexpr char EXPOSURE_CONFIG_DURATION[] = "duration";
|
||||
|
||||
class ExposureProcessor : public AceType {
|
||||
DECLARE_ACE_TYPE(ExposureProcessor, AceType)
|
||||
|
||||
|
@ -4581,6 +4581,50 @@ void FrameNode::OnInspectorIdUpdate(const std::string& id)
|
||||
}
|
||||
}
|
||||
|
||||
void FrameNode::OnAutoEventParamUpdate(const std::string& value)
|
||||
{
|
||||
if (value.empty()) {
|
||||
return;
|
||||
}
|
||||
auto paramJson = JsonUtil::ParseJsonString(value);
|
||||
if (paramJson == nullptr || !paramJson->IsValid() || !paramJson->IsObject()) {
|
||||
return;
|
||||
}
|
||||
if (paramJson->Contains(Recorder::ORIGIN_PARAM)) {
|
||||
propAutoEventParam_ = paramJson->GetValue(Recorder::ORIGIN_PARAM)->ToString();
|
||||
}
|
||||
if (exposureProcessor_ && exposureProcessor_->isListening()) {
|
||||
return;
|
||||
}
|
||||
if (!paramJson->Contains(Recorder::EXPOSURE_CONFIG_PARAM)) {
|
||||
return;
|
||||
}
|
||||
auto exposureCfg = paramJson->GetValue(Recorder::EXPOSURE_CONFIG_PARAM);
|
||||
if (exposureCfg && exposureCfg->IsObject()) {
|
||||
auto ratio = exposureCfg->GetDouble(Recorder::EXPOSURE_CONFIG_RATIO);
|
||||
auto duration = exposureCfg->GetInt(Recorder::EXPOSURE_CONFIG_DURATION);
|
||||
if (duration <= 0) {
|
||||
return;
|
||||
}
|
||||
auto* context = GetContext();
|
||||
CHECK_NULL_VOID(context);
|
||||
context->AddAfterRenderTask([weak = WeakClaim(this), ratio, duration]() {
|
||||
auto host = weak.Upgrade();
|
||||
CHECK_NULL_VOID(host);
|
||||
if (host->exposureProcessor_ && host->exposureProcessor_->isListening()) {
|
||||
return;
|
||||
}
|
||||
auto pageUrl = Recorder::GetPageUrlByNode(host);
|
||||
host->exposureProcessor_ =
|
||||
MakeRefPtr<Recorder::ExposureProcessor>(pageUrl, host->GetInspectorIdValue(""), ratio, duration);
|
||||
if (!host->exposureProcessor_->IsNeedRecord()) {
|
||||
return;
|
||||
}
|
||||
host->RecordExposureInner();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void FrameNode::SetExposureProcessor(const RefPtr<Recorder::ExposureProcessor>& processor)
|
||||
{
|
||||
if (exposureProcessor_ && exposureProcessor_->isListening()) {
|
||||
|
@ -146,6 +146,8 @@ public:
|
||||
|
||||
void OnInspectorIdUpdate(const std::string& id) override;
|
||||
|
||||
void OnAutoEventParamUpdate(const std::string& value) override;
|
||||
|
||||
void UpdateGeometryTransition() override;
|
||||
|
||||
struct ZIndexComparator {
|
||||
|
@ -1926,4 +1926,33 @@ HWTEST_F(FrameNodeTestNg, FrameNodeRemoveCustomProperty063, TestSize.Level1)
|
||||
bool result = frameNode->GetCapiCustomProperty("key", value);
|
||||
EXPECT_EQ(result, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: FrameNodeTestNg_OnAutoEventParamUpdate
|
||||
* @tc.desc: Test frame node method
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(FrameNodeTestNg, FrameNodeTestNg_OnAutoEventParamUpdate, TestSize.Level1)
|
||||
{
|
||||
/**
|
||||
* @tc.steps: step1. create framenode and initialize the params used in Test.
|
||||
*/
|
||||
auto node = FrameNode::CreateFrameNode("childNode", 10, AceType::MakeRefPtr<Pattern>(), true);
|
||||
node->AttachToMainTree();
|
||||
node->GetRenderContext()->RequestNextFrame();
|
||||
EXPECT_TRUE(node->IsOnMainTree());
|
||||
|
||||
int32_t nodeId = ElementRegister::GetInstance()->MakeUniqueId();
|
||||
const RefPtr<FrameNode> parentNode =
|
||||
FrameNode::CreateFrameNode("RelativeContainer", nodeId, AceType::MakeRefPtr<Pattern>(), true);
|
||||
node->SetParent(AceType::WeakClaim(AceType::RawPtr(parentNode)));
|
||||
|
||||
/**
|
||||
* @tc.steps: step2. call OnAutoEventParamUpdate.
|
||||
* @tc.expect: this parentNode is MarkDirtyNode, but this Tag() != "RelativeContainer"
|
||||
* this parentNode is not MarkDirtyNode
|
||||
*/
|
||||
node->OnAutoEventParamUpdate("{\"$origin\":\"Tom\",\"$exposureCfg\":{\"ratio\":0.8,\"duration\":3000}}");
|
||||
EXPECT_EQ(parentNode->GetTag(), "RelativeContainer");
|
||||
}
|
||||
} // namespace OHOS::Ace::NG
|
||||
|
Loading…
Reference in New Issue
Block a user