SurfaceTextureClient_test.cpp revision 391bbe2246a7547dbf3460c231b3c5ba691d4eb1
1/*
2 * Copyright (C) 2011 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 <gui/SurfaceTextureClient.h>
18#include <gtest/gtest.h>
19
20namespace android {
21
22class SurfaceTextureClientTest : public ::testing::Test {
23protected:
24    virtual void SetUp() {
25        mST = new SurfaceTexture(123);
26        mSTC = new SurfaceTextureClient(mST);
27    }
28
29    virtual void TearDown() {
30        mST.clear();
31        mSTC.clear();
32    }
33
34    sp<SurfaceTexture> mST;
35    sp<SurfaceTextureClient> mSTC;
36};
37
38TEST_F(SurfaceTextureClientTest, QueuesToWindowCompositorIsFalse) {
39    sp<ANativeWindow> anw(mSTC);
40    int result = -123;
41    int err = anw->query(anw.get(), NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER,
42            &result);
43    EXPECT_EQ(NO_ERROR, err);
44    EXPECT_EQ(0, result);
45}
46
47TEST_F(SurfaceTextureClientTest, ConcreteTypeIsSurfaceTextureClient) {
48    sp<ANativeWindow> anw(mSTC);
49    int result = -123;
50    int err = anw->query(anw.get(), NATIVE_WINDOW_CONCRETE_TYPE, &result);
51    EXPECT_EQ(NO_ERROR, err);
52    EXPECT_EQ(NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT, result);
53}
54
55}
56