~ubuntu-branches/ubuntu/wily/mir/wily-proposed

« back to all changes in this revision

Viewing changes to tests/unit-tests/graphics/android/test_hwc_logger.cpp

  • Committer: Package Import Robot
  • Author(s): CI Train Bot
  • Date: 2015-05-12 13:12:55 UTC
  • mto: This revision was merged to the branch mainline in revision 96.
  • Revision ID: package-import@ubuntu.com-20150512131255-y7z12i8n4pbvo70x
Tags: upstream-0.13.0+15.10.20150512
ImportĀ upstreamĀ versionĀ 0.13.0+15.10.20150512

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
{
29
29
struct HwcLogger : public ::testing::Test
30
30
{
31
 
    HwcLogger()
32
 
     : num_layers{4},
33
 
       display_list{std::shared_ptr<hwc_display_contents_1_t>(
34
 
            static_cast<hwc_display_contents_1_t*>(
35
 
           ::operator new(sizeof(hwc_display_contents_1_t) + (num_layers * sizeof(hwc_layer_1_t)))))}
 
31
    void fill_display_list(hwc_display_contents_1_t* display_list)
36
32
    {
37
 
        default_cout_buffer = std::cout.rdbuf();
38
 
        std::cout.rdbuf(test_stream.rdbuf());
39
 
 
40
33
        display_list->numHwLayers = num_layers;
41
34
 
42
35
        display_list->hwLayers[0].compositionType = HWC_OVERLAY;
46
39
        display_list->hwLayers[0].blending = HWC_BLENDING_NONE;
47
40
        display_list->hwLayers[0].displayFrame = {1, 1, 2, 1}; 
48
41
        display_list->hwLayers[0].sourceCrop = {3, 2, 5, 3}; 
 
42
        display_list->hwLayers[0].acquireFenceFd = fake_fence[0];
 
43
        display_list->hwLayers[0].releaseFenceFd = fake_fence[1];
49
44
 
50
45
        display_list->hwLayers[1].compositionType = HWC_FRAMEBUFFER; 
51
46
        display_list->hwLayers[1].flags = 0;
54
49
        display_list->hwLayers[1].blending = HWC_BLENDING_PREMULT;
55
50
        display_list->hwLayers[1].displayFrame = {8, 5, 13, 8}; 
56
51
        display_list->hwLayers[1].sourceCrop = {21, 13, 34, 21}; 
 
52
        display_list->hwLayers[1].acquireFenceFd = fake_fence[2];
 
53
        display_list->hwLayers[1].releaseFenceFd = fake_fence[3];
57
54
 
58
55
        display_list->hwLayers[2].compositionType = HWC_FRAMEBUFFER; 
59
56
        display_list->hwLayers[2].flags = HWC_SKIP_LAYER;
62
59
        display_list->hwLayers[2].blending = HWC_BLENDING_COVERAGE; 
63
60
        display_list->hwLayers[2].displayFrame = {55, 34, 89, 55};  
64
61
        display_list->hwLayers[2].sourceCrop = {144, 89, 233, 144}; 
 
62
        display_list->hwLayers[2].acquireFenceFd = fake_fence[4];
 
63
        display_list->hwLayers[2].releaseFenceFd = fake_fence[5];
65
64
 
66
65
        display_list->hwLayers[3].compositionType = HWC_FRAMEBUFFER_TARGET; 
67
66
        display_list->hwLayers[3].flags = 0; 
69
68
        display_list->hwLayers[3].transform = 0;
70
69
        display_list->hwLayers[3].blending = HWC_BLENDING_NONE; 
71
70
        display_list->hwLayers[3].displayFrame = {377, 233, 610, 337}; 
72
 
        display_list->hwLayers[3].sourceCrop = {987, 610, 1597, 987};  
 
71
        display_list->hwLayers[3].sourceCrop = {987, 610, 1597, 987};
 
72
        display_list->hwLayers[3].acquireFenceFd = fake_fence[6];
 
73
        display_list->hwLayers[3].releaseFenceFd = fake_fence[7];
 
74
    }
 
75
 
 
76
    HwcLogger()
 
77
     : num_layers{4},
 
78
       primary_list{std::shared_ptr<hwc_display_contents_1_t>(
 
79
            static_cast<hwc_display_contents_1_t*>(
 
80
           ::operator new(sizeof(hwc_display_contents_1_t) + (num_layers * sizeof(hwc_layer_1_t)))))},
 
81
       external_list{std::shared_ptr<hwc_display_contents_1_t>(
 
82
            static_cast<hwc_display_contents_1_t*>(
 
83
           ::operator new(sizeof(hwc_display_contents_1_t) + (num_layers * sizeof(hwc_layer_1_t)))))}
 
84
    {
 
85
        default_cout_buffer = std::cout.rdbuf();
 
86
        std::cout.rdbuf(test_stream.rdbuf());
 
87
 
 
88
        fill_display_list(primary_list.get());
 
89
        fill_display_list(external_list.get());
 
90
        display_list[HWC_DISPLAY_PRIMARY] = primary_list.get();
 
91
        display_list[HWC_DISPLAY_EXTERNAL] = external_list.get();
 
92
        display_list[HWC_DISPLAY_VIRTUAL] = nullptr;
73
93
    };
74
94
 
75
95
    virtual ~HwcLogger()
80
100
    decltype(std::cout.rdbuf()) default_cout_buffer;
81
101
    std::ostringstream test_stream;
82
102
    size_t const num_layers;
83
 
    std::shared_ptr<hwc_display_contents_1_t> const display_list;
 
103
    std::shared_ptr<hwc_display_contents_1_t> const primary_list;
 
104
    std::shared_ptr<hwc_display_contents_1_t> const external_list;
 
105
    std::array<hwc_display_contents_1_t*, HWC_NUM_DISPLAY_TYPES> display_list;
 
106
    std::array<int, 8> const fake_fence{ {4,5,6,7,8,9,10,11} };
84
107
    native_handle_t native_handle1;
85
108
    native_handle_t native_handle2;
86
109
    native_handle_t native_handle3;
92
115
{
93
116
    std::stringstream str;
94
117
    str << "before prepare():" << std::endl
95
 
        << " # | pos {l,t,r,b}         | crop {l,t,r,b}        | transform | blending | " << std::endl
96
 
        << " 0 | {   1,   1,   2,   1} | {   3,   2,   5,   3} | ROT_90    | NONE     | " << std::endl
97
 
        << " 1 | {   8,   5,  13,   8} | {  21,  13,  34,  21} | ROT_180   | PREMULT  | " << std::endl
98
 
        << " 2 | {  55,  34,  89,  55} | { 144,  89, 233, 144} | ROT_270   | COVERAGE | " << std::endl
99
 
        << " 3 | { 377, 233, 610, 337} | { 987, 610,1597, 987} | NONE      | NONE     | " << std::endl;
 
118
        << " # | display  | Type      | pos {l,t,r,b}         | crop {l,t,r,b}        | transform | blending | " << std::endl
 
119
        << " 0 | primary  | OVERLAY   | {   1,   1,   2,   1} | {   3,   2,   5,   3} | ROT_90    | NONE     | " << std::endl
 
120
        << " 1 | primary  | GL_RENDER | {   8,   5,  13,   8} | {  21,  13,  34,  21} | ROT_180   | PREMULT  | " << std::endl
 
121
        << " 2 | primary  | FORCE_GL  | {  55,  34,  89,  55} | { 144,  89, 233, 144} | ROT_270   | COVERAGE | " << std::endl
 
122
        << " 3 | primary  | FB_TARGET | { 377, 233, 610, 337} | { 987, 610,1597, 987} | NONE      | NONE     | " << std::endl
 
123
        << " 0 | external | OVERLAY   | {   1,   1,   2,   1} | {   3,   2,   5,   3} | ROT_90    | NONE     | " << std::endl
 
124
        << " 1 | external | GL_RENDER | {   8,   5,  13,   8} | {  21,  13,  34,  21} | ROT_180   | PREMULT  | " << std::endl
 
125
        << " 2 | external | FORCE_GL  | {  55,  34,  89,  55} | { 144,  89, 233, 144} | ROT_270   | COVERAGE | " << std::endl
 
126
        << " 3 | external | FB_TARGET | { 377, 233, 610, 337} | { 987, 610,1597, 987} | NONE      | NONE     | " << std::endl;
100
127
    mga::HwcFormattedLogger logger;
101
 
    logger.report_list_submitted_to_prepare(*display_list);
 
128
    logger.set_version(mga::HwcVersion::hwc12);
 
129
    logger.report_list_submitted_to_prepare(display_list);
102
130
    EXPECT_EQ(str.str(), test_stream.str()); 
103
131
}
104
132
 
106
134
{
107
135
    std::stringstream str;
108
136
    str << "after prepare():" << std::endl 
109
 
        << " # | Type      | " << std::endl
110
 
        << " 0 | OVERLAY   | " << std::endl
111
 
        << " 1 | GL_RENDER | " << std::endl
112
 
        << " 2 | FORCE_GL  | " << std::endl
113
 
        << " 3 | FB_TARGET | " << std::endl;
 
137
        << " # | display  | Type      | " << std::endl
 
138
        << " 0 | primary  | OVERLAY   | " << std::endl
 
139
        << " 1 | primary  | GL_RENDER | " << std::endl
 
140
        << " 2 | primary  | FORCE_GL  | " << std::endl
 
141
        << " 3 | primary  | FB_TARGET | " << std::endl
 
142
        << " 0 | external | OVERLAY   | " << std::endl
 
143
        << " 1 | external | GL_RENDER | " << std::endl
 
144
        << " 2 | external | FORCE_GL  | " << std::endl
 
145
        << " 3 | external | FB_TARGET | " << std::endl;
114
146
    mga::HwcFormattedLogger logger;
115
 
    logger.report_prepare_done(*display_list);
 
147
    logger.report_prepare_done(display_list);
116
148
    EXPECT_EQ(str.str(), test_stream.str()); 
117
149
}
118
150
 
120
152
{
121
153
    std::stringstream str;
122
154
    str << "set list():" << std::endl
123
 
        << " # | handle" << std::endl
124
 
        << " 0 | " << &native_handle1 << std::endl 
125
 
        << " 1 | " << &native_handle2 << std::endl 
126
 
        << " 2 | " << &native_handle3 << std::endl 
127
 
        << " 3 | " << &native_handle4 << std::endl; 
128
 
 
129
 
    mga::HwcFormattedLogger logger;
130
 
    logger.report_set_list(*display_list);
 
155
        << " # | display  | Type      | handle | acquireFenceFd" << std::endl
 
156
        << " 0 | primary  | OVERLAY   | " << &native_handle1 << " | " << fake_fence[0] << std::endl
 
157
        << " 1 | primary  | GL_RENDER | " << &native_handle2 << " | " << fake_fence[2] << std::endl
 
158
        << " 2 | primary  | FORCE_GL  | " << &native_handle3 << " | " << fake_fence[4] << std::endl
 
159
        << " 3 | primary  | FB_TARGET | " << &native_handle4 << " | " << fake_fence[6] << std::endl
 
160
        << " 0 | external | OVERLAY   | " << &native_handle1 << " | " << fake_fence[0] << std::endl
 
161
        << " 1 | external | GL_RENDER | " << &native_handle2 << " | " << fake_fence[2] << std::endl
 
162
        << " 2 | external | FORCE_GL  | " << &native_handle3 << " | " << fake_fence[4] << std::endl
 
163
        << " 3 | external | FB_TARGET | " << &native_handle4 << " | " << fake_fence[6] << std::endl;
 
164
 
 
165
    mga::HwcFormattedLogger logger;
 
166
    logger.report_set_list(display_list);
 
167
    EXPECT_EQ(str.str(), test_stream.str()); 
 
168
}
 
169
 
 
170
TEST_F(HwcLogger, report_post_set)
 
171
{
 
172
    std::stringstream str;
 
173
    str << "after set():" << std::endl
 
174
        << " # | display  | releaseFenceFd" << std::endl
 
175
        << " 0 | primary  | " << fake_fence[1] << std::endl 
 
176
        << " 1 | primary  | " << fake_fence[3] << std::endl 
 
177
        << " 2 | primary  | " << fake_fence[5] << std::endl 
 
178
        << " 3 | primary  | " << fake_fence[7] << std::endl
 
179
        << " 0 | external | " << fake_fence[1] << std::endl 
 
180
        << " 1 | external | " << fake_fence[3] << std::endl 
 
181
        << " 2 | external | " << fake_fence[5] << std::endl 
 
182
        << " 3 | external | " << fake_fence[7] << std::endl; 
 
183
 
 
184
    mga::HwcFormattedLogger logger;
 
185
    logger.report_set_done(display_list);
131
186
    EXPECT_EQ(str.str(), test_stream.str()); 
132
187
}
133
188
 
214
269
    logger.report_hwc_version(mga::HwcVersion::hwc14);
215
270
    EXPECT_EQ(str.str(), test_stream.str()); 
216
271
}
 
272
 
 
273
TEST_F(HwcLogger, report_power_mode)
 
274
{
 
275
    std::stringstream str;
 
276
    str << "HWC: power mode: off" << std::endl
 
277
        << "HWC: power mode: doze" << std::endl
 
278
        << "HWC: power mode: doze(suspend)" << std::endl
 
279
        << "HWC: power mode: on(normal)" << std::endl;
 
280
 
 
281
    mga::HwcFormattedLogger logger;
 
282
    logger.report_power_mode(mga::PowerMode::off);
 
283
    logger.report_power_mode(mga::PowerMode::doze);
 
284
    logger.report_power_mode(mga::PowerMode::doze_suspend);
 
285
    logger.report_power_mode(mga::PowerMode::normal);
 
286
 
 
287
    EXPECT_EQ(str.str(), test_stream.str());
 
288
}