LeakCheckTests.cpp revision 6e068c0182f6f85bccb855a647510724d1c65a13
1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "BakedOpRenderer.h"
18#include "BakedOpDispatcher.h"
19#include "FrameBuilder.h"
20#include "LayerUpdateQueue.h"
21#include "RecordingCanvas.h"
22#include "tests/common/TestUtils.h"
23
24#include <gtest/gtest.h>
25
26using namespace android;
27using namespace android::uirenderer;
28
29const LayerUpdateQueue sEmptyLayerUpdateQueue;
30const FrameBuilder::LightGeometry sLightGeometery = { {100, 100, 100}, 50};
31const BakedOpRenderer::LightInfo sLightInfo = { 128, 128 };
32
33RENDERTHREAD_TEST(LeakCheck, saveLayerUnclipped_simple) {
34    auto node = TestUtils::createNode(0, 0, 200, 200,
35            [](RenderProperties& props, RecordingCanvas& canvas) {
36        canvas.saveLayerAlpha(10, 10, 190, 190, 128, (SaveFlags::Flags)(0));
37        canvas.drawRect(0, 0, 200, 200, SkPaint());
38        canvas.restore();
39    });
40    RenderState& renderState = renderThread.renderState();
41    Caches& caches = Caches::getInstance();
42
43    FrameBuilder frameBuilder(sEmptyLayerUpdateQueue, SkRect::MakeWH(200, 200), 200, 200,
44            TestUtils::createSyncedNodeList(node), sLightGeometery, nullptr);
45    BakedOpRenderer renderer(caches, renderState, true, sLightInfo);
46    frameBuilder.replayBakedOps<BakedOpDispatcher>(renderer);
47}
48