~alan-griffiths/miral/debug

« back to all changes in this revision

Viewing changes to test/window_placement_client_api.cpp

  • Committer: Alan Griffiths
  • Date: 2016-09-14 09:03:34 UTC
  • Revision ID: alam@octopull.co.uk-20160914090334-r7oyyrmp68dwo5se
Tidy code

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
        auto spec = SurfaceSpec::for_normal_surface(connection, 400, 400, mir_pixel_format_argb_8888)
52
52
            .set_name(test_name);
53
53
 
54
 
        parent = Surface{spec.create_surface()};
 
54
        parent = spec.create_surface();
55
55
    }
56
56
 
57
57
    void TearDown() override
108
108
};
109
109
}
110
110
 
111
 
TEST_F(WindowPlacementClientAPI, given_menu_placement_away_from_edges_when_notified_result_is_as_requested)
 
111
// It would be nice to verify creation and movement placement notifications in separate tests,
 
112
// However, to avoid a racy test, we need to detect both anyway. This seems like a good trade-off.
 
113
TEST_F(WindowPlacementClientAPI, given_menu_placements_away_from_edges_when_notified_result_is_as_requested)
112
114
{
113
115
    char const* const test_name = __PRETTY_FUNCTION__;
114
 
 
115
 
    MirRectangle aux_rect{10, 20, 3, 4};
116
 
 
117
116
    int const dx = 30;
118
117
    int const dy = 40;
119
118
 
120
 
    CheckPlacement expected{aux_rect.left+(int)aux_rect.width, aux_rect.top, dx, dy};
121
 
 
122
 
    auto spec = SurfaceSpec::for_for_menu(connection, dx, dy, mir_pixel_format_argb_8888, parent, &aux_rect, mir_edge_attachment_any)
123
 
        .set_event_handler(&CheckPlacement::callback, &expected)
124
 
        .set_name(test_name);
125
 
 
126
 
    spec.create_surface();
 
119
    // initial placement
 
120
    {
 
121
        MirRectangle aux_rect{10, 20, 3, 4};
 
122
        CheckPlacement expected{aux_rect.left+(int)aux_rect.width, aux_rect.top, dx, dy};
 
123
 
 
124
        auto const spec = SurfaceSpec::
 
125
            for_for_menu(connection, dx, dy, mir_pixel_format_argb_8888, parent, &aux_rect, mir_edge_attachment_any)
 
126
            .set_event_handler(&CheckPlacement::callback, &expected)
 
127
            .set_name(test_name);
 
128
 
 
129
        child = spec.create_surface();
 
130
    }
 
131
 
 
132
    // subsequent movement
 
133
    {
 
134
        MirRectangle aux_rect{50, 60, 5, 7};
 
135
        CheckPlacement expected{aux_rect.left-dx, aux_rect.top, dx, dy};
 
136
 
 
137
        auto const spec = SurfaceSpec::for_changes(connection)
 
138
            .set_event_handler(&CheckPlacement::callback, &expected)
 
139
            .set_placement(&aux_rect, mir_placement_gravity_northwest, mir_placement_gravity_northeast, mir_placement_hints_flip_x, 0, 0);
 
140
 
 
141
        spec.apply_to(child);
 
142
    }
127
143
}
128
144
#endif
129