SurfaceTextureClient_test.cpp revision bae774eb20bebd409441b93386b51bccda75f546
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, GetISurfaceTextureIsNotNull) {
39    sp<ISurfaceTexture> ist(mSTC->getISurfaceTexture());
40    ASSERT_TRUE(ist != NULL);
41}
42
43TEST_F(SurfaceTextureClientTest, QueuesToWindowCompositorIsFalse) {
44    sp<ANativeWindow> anw(mSTC);
45    int result = -123;
46    int err = anw->query(anw.get(), NATIVE_WINDOW_QUEUES_TO_WINDOW_COMPOSER,
47            &result);
48    EXPECT_EQ(NO_ERROR, err);
49    EXPECT_EQ(0, result);
50}
51
52TEST_F(SurfaceTextureClientTest, ConcreteTypeIsSurfaceTextureClient) {
53    sp<ANativeWindow> anw(mSTC);
54    int result = -123;
55    int err = anw->query(anw.get(), NATIVE_WINDOW_CONCRETE_TYPE, &result);
56    EXPECT_EQ(NO_ERROR, err);
57    EXPECT_EQ(NATIVE_WINDOW_SURFACE_TEXTURE_CLIENT, result);
58}
59
60}
61