1 // Copyright (C) 2015 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "android/opengl/GpuFrameBridge.h"
16
17 #include "android/base/async/Looper.h"
18 #include "android/base/Log.h"
19 #include "android/base/memory/ScopedPtr.h"
20
21 #include <gtest/gtest.h>
22
23 #include <errno.h>
24 #include <stdlib.h>
25 #include <string.h>
26
27 namespace android {
28 namespace opengl {
29
30 using android::base::ScopedPtr;
31 using android::base::Looper;
32
TEST(GpuFrameBridge,postFrameWithinSingleThread)33 TEST(GpuFrameBridge, postFrameWithinSingleThread) {
34 GpuFrameBridge* bridge =
35 GpuFrameBridge::create();
36 EXPECT_TRUE(bridge);
37
38 static const unsigned char kFrame0[4] = {
39 0xff, 0x80, 0x40, 0xff,
40 };
41
42 bridge->postRecordFrame(1, 1, kFrame0);
43 unsigned char* pixel = (unsigned char*)bridge->getRecordFrame();
44 for (size_t n = 0; n < sizeof(kFrame0); ++n) {
45 EXPECT_EQ(kFrame0[n], pixel[n]) << "# " << n;
46 }
47 }
48
49 } // namespace opengl
50 } // namespace android
51