Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d66bdb5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Test RenderNode's prepareTree when its DL is null and non-null" into nyc-mr1-dev

parents 6b494179 a7952b33
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -16,13 +16,26 @@

#include <gtest/gtest.h>

#include "AnimationContext.h"
#include "DamageAccumulator.h"
#include "IContextFactory.h"
#include "RenderNode.h"
#include "TreeInfo.h"
#include "renderthread/CanvasContext.h"
#include "tests/common/TestUtils.h"
#include "utils/Color.h"

using namespace android;
using namespace android::uirenderer;
using namespace android::uirenderer::renderthread;

class ContextFactory : public android::uirenderer::IContextFactory {
public:
    android::uirenderer::AnimationContext* createAnimationContext
        (android::uirenderer::renderthread::TimeLord& clock) override {
        return new android::uirenderer::AnimationContext(clock);
    }
};

TEST(RenderNode, hasParents) {
    auto child = TestUtils::createNode(0, 0, 200, 400,
@@ -89,3 +102,31 @@ TEST(RenderNode, releasedCallback) {
    TestUtils::syncHierarchyPropertiesAndDisplayList(node);
    EXPECT_EQ(0, refcnt);
}

RENDERTHREAD_TEST(RenderNode, prepareTree_nullableDisplayList) {
    ContextFactory contextFactory;
    CanvasContext canvasContext(renderThread, false, nullptr, &contextFactory);
    TreeInfo info(TreeInfo::MODE_RT_ONLY, canvasContext);
    DamageAccumulator damageAccumulator;
    info.damageAccumulator = &damageAccumulator;
    info.observer = nullptr;

    {
        auto nonNullDLNode = TestUtils::createNode(0, 0, 200, 400,
                [](RenderProperties& props, TestCanvas& canvas) {
            canvas.drawColor(Color::Red_500, SkXfermode::kSrcOver_Mode);
        });
        TestUtils::syncHierarchyPropertiesAndDisplayList(nonNullDLNode);
        EXPECT_TRUE(nonNullDLNode->getDisplayList());
        nonNullDLNode->prepareTree(info);
    }

    {
        auto nullDLNode = TestUtils::createNode(0, 0, 200, 400, nullptr);
        TestUtils::syncHierarchyPropertiesAndDisplayList(nullDLNode);
        EXPECT_FALSE(nullDLNode->getDisplayList());
        nullDLNode->prepareTree(info);
    }

    canvasContext.destroy(nullptr);
}