~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/unit-tests/client/test_mir_screencast.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Kevin Gunn
  • Date: 2014-02-12 18:29:29 UTC
  • mfrom: (1.1.56)
  • Revision ID: package-import@ubuntu.com-20140212182929-ru6hzd1hqdf98tub
Tags: 0.1.5+14.04.20140212-0ubuntu1
[ Kevin Gunn ]
* Cherry-picked from future release 0.1.6:
  - frontend, shell: provide the client process ID in the shell::Session
    interface (LP: #1276704)
* New upstream release 0.1.5 (https://launchpad.net/mir/+milestone/0.1.5)
  - mirclient ABI bumped to 7
  - mirserver ABI bumped to 15
  - Refactoring to support client-controled RPC.
  - Add an translucent server example (use sparingly, this will kill
    performance!)
  - Add workaround for Qualcomm Snapdragon 8960 driver bug.
  - android-input: Improve debug output
  - Screen rotation support half done (rotation of the screen works but input
    rotation not implemented yet).
  - Add groundwork for overlay support to take better advantage of mobile
    hardware features and optimize composition in future.
  - Add support for HWC 1.2 (Android 4.4)
  - Add groundwork for screencasting (screen recording).
  - Optimized surface resizing, significantly reducing event flooding for
    some input configurations like touch.
  - Bugs fixed:
    . Surfaces no longer visible at all on Nexus 10 (LP: #1271853)
    . mir nested server failure: what(): error binding buffer to texture
      (LP: #1272041)
    . Unity does not process events from evdev device created before unity is
      restarted (autopilot tests) (LP: #1238417)
    . mir_unit_tests can't run on touch images any more (missing
      libumockdev.so.0) (LP: #1271434)
    . chmod 777 /tmp/mir_socket is no longer sufficient for non-root clients
      to connect to a root server (LP: #1272143)
    . Nexus7(2013) flo framerate maxes out at 30fps (LP: #1274189)
    . libmirserver user is unable to #include
       <mir/frontend/template_protobuf_message_processor.h> (LP: #1276162)
    . libmirclient user cannot "#include <mir/client/private.h>"
      (LP: #1276565)
    . AndroidInternalClient.internal_client_creation_and_use hangs on Nexus
      10 (LP: #1270685)
    . Tests that use the InProcessServer bind the default socket file
      (LP: #1271604)
    . BasicConnector threads exit immediately (LP: #1271655)
    . Integration tests TestClientIPCRender.test_accelerated_render fails on
      Galaxy Nexus and Nexus4 (LP: #1272597)
    . Android backend unit-tests FTBS on amd64 (LP: #1276621)
    . Erroneous use of last_consumed in SwitchingBundle::compositor_acquire
      (LP: #1270964)

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
    void create_screencast(
68
68
        google::protobuf::RpcController* /*controller*/,
69
69
        mp::ScreencastParameters const* /*request*/,
70
 
        mp::Screencast* /*response*/,
 
70
        mp::Screencast* response,
71
71
        google::protobuf::Closure* done) override
72
72
    {
73
73
        if (server_thread.joinable())
74
74
            server_thread.join();
75
 
        server_thread = std::thread{[done, this] { done->Run(); }};
 
75
        server_thread = std::thread{
 
76
            [response, done, this]
 
77
            {
 
78
                response->clear_error();
 
79
                done->Run();
 
80
            }};
76
81
    }
77
82
 
78
83
    void release_screencast(
151
156
 
152
157
ACTION_P(SetCreateScreencastId, screencast_id)
153
158
{
 
159
    arg2->clear_error();
154
160
    arg2->mutable_screencast_id()->set_value(screencast_id);
155
161
}
156
162
 
166
172
 
167
173
ACTION_P(SetCreateBufferFromPackage, package)
168
174
{
 
175
    arg2->clear_error();
169
176
    auto buffer = arg2->mutable_buffer();
170
177
    for (int i = 0; i != package.data_items; ++i)
171
178
    {
180
187
    buffer->set_stride(package.stride);
181
188
}
182
189
 
 
190
ACTION(SetCreateError)
 
191
{
 
192
    arg2->set_error("Test error");
 
193
}
 
194
 
183
195
ACTION(RunClosure)
184
196
{
185
197
    arg3->Run();
521
533
 
522
534
    EXPECT_EQ(StubEGLNativeWindowFactory::egl_native_window, egl_native_window);
523
535
}
 
536
 
 
537
TEST_F(MirScreencastTest, is_invalid_if_server_create_screencast_fails)
 
538
{
 
539
    using namespace testing;
 
540
 
 
541
    EXPECT_CALL(mock_server, create_screencast(_,_,_,_))
 
542
        .WillOnce(DoAll(SetCreateError(), RunClosure()));
 
543
 
 
544
    MirScreencast screencast{
 
545
        default_mir_output, mock_server,
 
546
        stub_egl_native_window_factory,
 
547
        stub_client_buffer_factory,
 
548
        null_callback_func, nullptr};
 
549
 
 
550
    screencast.creation_wait_handle()->wait_for_all();
 
551
 
 
552
    EXPECT_FALSE(screencast.valid());
 
553
}
 
554
 
 
555
TEST_F(MirScreencastTest, calls_callback_on_creation_failure)
 
556
{
 
557
    using namespace testing;
 
558
 
 
559
    MockCallback mock_cb;
 
560
    EXPECT_CALL(mock_server, create_screencast(_,_,_,_))
 
561
        .WillOnce(DoAll(SetCreateError(), RunClosure()));
 
562
    EXPECT_CALL(mock_cb, call(_,&mock_cb));
 
563
 
 
564
    MirScreencast screencast{
 
565
        default_mir_output, mock_server,
 
566
        stub_egl_native_window_factory,
 
567
        stub_client_buffer_factory,
 
568
        mock_callback_func, &mock_cb};
 
569
 
 
570
    screencast.creation_wait_handle()->wait_for_all();
 
571
 
 
572
    EXPECT_FALSE(screencast.valid());
 
573
}