blob: 42ba3dbd2362cd2168c276989a873d41f2b15261 [file] [log] [blame]
Derek Sollenbergerdaf72292016-10-25 12:09:18 -04001/*
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 <gtest/gtest.h>
18
19#include "AnimationContext.h"
20#include "IContextFactory.h"
21#include "renderthread/CanvasContext.h"
22#include "tests/common/TestUtils.h"
23
24using namespace android;
25using namespace android::uirenderer;
26using namespace android::uirenderer::renderthread;
27
28class ContextFactory : public IContextFactory {
29public:
30 virtual AnimationContext* createAnimationContext(renderthread::TimeLord& clock) override {
31 return new AnimationContext(clock);
32 }
33};
34
35RENDERTHREAD_TEST(CanvasContext, create) {
36 auto rootNode = TestUtils::createNode(0, 0, 200, 400, nullptr);
37 ContextFactory contextFactory;
38 std::unique_ptr<CanvasContext> canvasContext(CanvasContext::create(
39 renderThread, false, rootNode.get(), &contextFactory));
40
41 ASSERT_FALSE(canvasContext->hasSurface());
42
43 canvasContext->destroy(nullptr);
44}
45
Derek Sollenbergerdaf72292016-10-25 12:09:18 -040046RENDERTHREAD_TEST(CanvasContext, invokeFunctor) {
Derek Sollenberger835b3a692016-10-28 13:57:14 -040047 TestUtils::MockFunctor functor;
Derek Sollenbergerdaf72292016-10-25 12:09:18 -040048 CanvasContext::invokeFunctor(renderThread, &functor);
Greg Daniel98c78dad2017-01-04 14:45:56 -050049 if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaVulkan) {
50 // we currently don't support OpenGL WebViews on the Vulkan backend
51 ASSERT_EQ(functor.getLastMode(), DrawGlInfo::kModeProcessNoContext);
52 } else {
53 ASSERT_EQ(functor.getLastMode(), DrawGlInfo::kModeProcess);
54 }
Derek Sollenbergerdaf72292016-10-25 12:09:18 -040055}