~sergiusens/libhybris/autotests

« back to all changes in this revision

Viewing changes to hybris/tests/test_ui.c

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2013-06-04 07:33:11 UTC
  • Revision ID: package-import@ubuntu.com-20130604073311-20ldi2hm1axkvjl1
Tags: upstream-0.1.0+git20130601+dfb2e26
ImportĀ upstreamĀ versionĀ 0.1.0+git20130601+dfb2e26

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013 Simon Busch <morphis@gravedo.de>
 
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 <assert.h>
 
18
 
 
19
#include <hybris/ui_compatibility_layer.h>
 
20
#include <android/hardware/gralloc.h>
 
21
#include <android/system/graphics.h>
 
22
 
 
23
int main(int argc, char **argv)
 
24
{
 
25
        struct graphic_buffer *buffer = 0;
 
26
 
 
27
        buffer = graphic_buffer_new();
 
28
 
 
29
        assert(buffer != NULL);
 
30
 
 
31
        graphic_buffer_free(buffer);
 
32
 
 
33
        buffer = graphic_buffer_new_sized(720, 1280, HAL_PIXEL_FORMAT_BGRA_8888, GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_TEXTURE);
 
34
 
 
35
        assert(buffer != NULL);
 
36
        assert(graphic_buffer_get_width(buffer) == 720);
 
37
        assert(graphic_buffer_get_height(buffer) == 1280);
 
38
        assert(graphic_buffer_get_usage(buffer) == (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER));
 
39
        assert(graphic_buffer_get_pixel_format(buffer) == HAL_PIXEL_FORMAT_BGRA_8888);
 
40
        assert(graphic_buffer_get_native_buffer(buffer) != NULL);
 
41
 
 
42
        graphic_buffer_reallocate(buffer, 480, 640, HAL_PIXEL_FORMAT_BGRA_8888, GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER);
 
43
 
 
44
        assert(buffer != NULL);
 
45
        assert(graphic_buffer_get_width(buffer) == 480);
 
46
        assert(graphic_buffer_get_height(buffer) == 640);
 
47
        assert(graphic_buffer_get_usage(buffer) == (GRALLOC_USAGE_HW_TEXTURE | GRALLOC_USAGE_HW_RENDER));
 
48
        assert(graphic_buffer_get_pixel_format(buffer) == HAL_PIXEL_FORMAT_BGRA_8888);
 
49
        assert(graphic_buffer_get_native_buffer(buffer) != NULL);
 
50
 
 
51
        void *vaddr = NULL;
 
52
        graphic_buffer_lock(buffer, GRALLOC_USAGE_HW_RENDER, &vaddr);
 
53
        graphic_buffer_unlock(buffer);
 
54
 
 
55
        graphic_buffer_set_index(buffer, 11);
 
56
        assert(graphic_buffer_get_index(buffer) == 11);
 
57
 
 
58
        graphic_buffer_free(buffer);
 
59
 
 
60
        return 0;
 
61
}