~ci-train-bot/mir/mir-ubuntu-zesty-2609

« back to all changes in this revision

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

  • Committer: Bileto Bot
  • Date: 2016-08-15 16:28:40 UTC
  • mfrom: (1160.2357.136 0.24)
  • Revision ID: ci-train-bot@canonical.com-20160815162840-98t95gfrcymlrwpc
* New upstream release 0.24.0 (https://launchpad.net/mir/+milestone/0.24.0)
  - ABI summary:
    . mirclient ABI unchanged at 9
    . mirserver ABI bumped to 41
    . mircommon ABI unchanged at 6
    . mirplatform ABI bumped to 12
    . mirprotobuf ABI unchanged at 3
    . mirplatformgraphics ABI bumped to 10
    . mirclientplatform ABI unchanged at 5
    . mirinputplatform ABI unchanged at 5
  - Enhancements:
    . Added a new tool 'mirvanity' which can use a high speed video camera
      to measure client-to-screen latency.
    . Added (build-time) support for desktop full OpenGL servers (disabled
      by default in favor of GLESv2).
    . Introduced new buffer semantics (NBS) and enabled it by default.
    . Avoided using libmirserver in mir_demo_standalone_render_overlays,
      making bringup traces less cluttered.
    . Removed TilingWindowManager from example servers.
    . Added two new mir_*_performance_test tools that are run as part of
      'mir_performance_tests'.
    . Added pointer confinement to the client API.
    . Added new platform supporting software EGLStreams.
    . Added an input platform that the nested server can use.
    . Allow configuration of the application_not_responding_detector
    . Handle server-side keymapping using XKBMapper.
    . Remove the offscreen display.
    . Add callback option to notify shells that the server is about to stop.
    . Add logging for ANativeWindow events on Android.
  - Bugs fixed:
    . usage of std:call_once in mirclient causes TLS collisions with some
      android devices (LP: #1599867)
    . AltGr not working on external keyboards (LP: #1565236)
    . [regression] unity8 fails to start when built with 0.24 series (lp:mir)
      (LP: #1597717)
    . CI failure in MirSurfaceVisibilityEvent.exposed_received_when_surface_
      raised_over_occluding_surface [called twice - over-saturated and active]
      (LP: #1556045)
    . package-built mir_demo_server does not start on device (LP: #1577357)
    . During surface creation, first stream in spec becomes default stream.
      (LP: #1577967)
    . mouse is getting stuck on a phantom edge (LP: #1580774)
    . [testsfail] in MirSurfaceVisibilityEvent.exposed_received_when_surface_
      raised_over_occluding_surface [never called] (LP: #1581385)
    . [enhancement] Add support for full OpenGL compositing (LP: #1420581)
    . [testsfail] ServerSignal.terminate_handler_is_called_for_SIGINT|SIGTERM
      (LP: #1570353)
    . [testsfail] ClientLatency.triple_buffered_client_has_less_than_two_
      frames_latency (LP: #1576690)
    . [testsfail] NestedServer.when_monitor_plugged_in_client_is_notified_of_
      new_display_configuration (LP: #1576760)
    . mir server crashed in what(): drmModeMoveCursor failed (returned -13)
      (LP: #1579630)
    . mirtest-dev is hard to use as the objects used are compiled with LTO
      (LP: #1583536)
    . [testsfail] ClientLogging.reports_performance [Value of: lag]
      (LP: #1583970)
    . [ FAILED ] ClientLogging.reports_performance (Value of: nbuffers)
      (LP: #1584603)
    . [ FAILED ] ClientLogging.reports_performance (Value of: render)
      (LP: #1584605)
    . ClientCredsTestFixture.session_authorizer_receives_pid_of_connecting_
      clients failure (LP: #1587604)
    . Mir on X11 ignores mir::graphics::GLConfig depth & stencil buffer size
      (LP: #1589632)
    . Need to support pointer confinement (LP: #1590099)
    . [tests] given_nested_server_set_base_display_configuration_when_
      monitor_plugged_in_configuration_is_reset fails (LP: #1591354)
    . CI failure in DemoInProcessServerWithStubClientPlatform.surface_
      creation_does_not_leak_fds (LP: #1598802)
    . Screen is squashed/distorted when rotated in Mir-on-X11 (LP: #1577262)
    . --display-report=log shows some invalid uninitialized EGL attribute
      values (LP: #1582066)
    . mir_demo_client_eglplasma falls back to software rendering on i915
      (Intel Atoms), which explains why it's so slow (LP: #1583532)
    . [regression] x11 platform only draws to a small part of the x11 window
      (LP: #1598267)
    . mir ftbfs in yakkety builders (LP: #1600343)
    . Autolanding keeps failing: mock_egl.h:89:7: error: type 'struct
      MockEGL' violates one definition rule [-Werror=odr] (LP: #1603303)
    . [regression] The Super/Windows key doesn't work any more (LP: #1602966)
    . mir_acceptance_tests.bin: double free or corruption (fasttop)
      (LP: #1603114)
    . ftbfs in linking libmir-test-assist.a in xenial+overlay and
      yakkety+overlay (LP: #1601810)
    . [testsfail] failure in NestedInput.on_input_device_state_nested_*
      (LP: #1602646)  
    . mirtest-dev provides an incorrect .pc file (LP: #1603080)
    . mir_test_framework::server_platform_path(), 
      mir_test_framework::server_platform() don't support use in a downstream
      test built against mir-test-assist (LP: #1603091)
    . Servers based on Mir need a hook to execute code when the server is
      closing (LP: #1593655)
    . Android graphics platform doesn't get packaged for arm64 (LP: #157866)
    . memory leaks in unit tests on android (LP: #1253486)
    . Physical "screen" size reported by the X11 backend is same as pixel
      count, fixing dpi to 25.4 (LP: #1596051)
    . Mir build and test failures with gcc-6 and LTO (LP: #1610215)
    . [regression] Trust prompt not shown when starting camera (LP: #1612256)
* No-change rebuild for boost soname change.
    . unity8/libmirclient gives up and terminates prematurely with
      "std::exception::what: disconnected: no new buffers" via
      ExchangeSemantics::submit() (LP: #1506358)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include "src/server/frontend/resource_cache.h" /* needed by test_server.h */
37
37
#include "mir/test/test_protobuf_server.h"
38
38
#include "mir/test/stub_server_tool.h"
 
39
#include "mir/test/doubles/mock_mir_buffer.h"
39
40
#include "mir/test/doubles/stub_client_buffer_factory.h"
40
41
 
41
42
#include "mir_protobuf.pb.h"
86
87
struct MockAsyncBufferFactory : mcl::AsyncBufferFactory
87
88
{
88
89
    MOCK_METHOD1(cancel_requests_with_context, void(void*));
89
 
    MOCK_METHOD1(generate_buffer, std::unique_ptr<mcl::Buffer>(mp::Buffer const&));
 
90
    MOCK_METHOD1(generate_buffer, std::unique_ptr<mcl::MirBuffer>(mp::Buffer const&));
90
91
    MOCK_METHOD7(expect_buffer, void(
91
92
        std::shared_ptr<mcl::ClientBufferFactory> const& native_buffer_factory,
92
 
        MirPresentationChain* chain,
 
93
        MirConnection* connection,
93
94
        geom::Size size,
94
95
        MirPixelFormat format,
95
96
        MirBufferUsage usage,
592
593
    config_wait_handle->wait_for_all();
593
594
}
594
595
 
595
 
static MirSurface *surface;
596
 
static void surface_callback(MirSurface* surf, void*)
597
 
{
598
 
    surface = surf;
599
 
}
600
 
 
601
 
static bool unfocused_received;
602
 
static void surface_event_callback(MirSurface *, MirEvent const *ev, void *)
603
 
{
604
 
    if (mir_event_type_surface != mir_event_get_type(ev))
605
 
        return;
606
 
    auto surface_ev = mir_event_get_surface_event(ev);
607
 
    if (mir_surface_attrib_focus != mir_surface_event_get_attribute(surface_ev))
608
 
        return;
609
 
    if (mir_surface_unfocused != mir_surface_event_get_attribute_value(surface_ev))
610
 
        return;
611
 
    unfocused_received = true;
612
 
}
613
 
 
614
 
TEST_F(MirConnectionTest, focused_window_synthesises_unfocus_event_on_release)
615
 
{
616
 
    using namespace testing;
617
 
 
618
 
    MirSurfaceSpec params{nullptr, 640, 480, mir_pixel_format_abgr_8888};
619
 
    params.surface_name = __PRETTY_FUNCTION__;
620
 
 
621
 
    unfocused_received = false;
622
 
 
623
 
    MirWaitHandle *wait_handle = connection->connect("MirClientSurfaceTest", &connected_callback, nullptr);
624
 
    wait_handle->wait_for_all();
625
 
 
626
 
    wait_handle = connection->create_surface(params, &surface_callback, nullptr);
627
 
    wait_handle->wait_for_all();
628
 
 
629
 
    surface->handle_event(*mev::make_event(mf::SurfaceId{surface->id()}, mir_surface_attrib_focus, mir_surface_focused));
630
 
 
631
 
    surface->set_event_handler(&surface_event_callback, nullptr);
632
 
 
633
 
    wait_handle = connection->release_surface(surface, &surface_callback, nullptr);
634
 
    wait_handle->wait_for_all();
635
 
 
636
 
    wait_handle = connection->disconnect();
637
 
    wait_handle->wait_for_all();
638
 
 
639
 
    EXPECT_TRUE(unfocused_received);
640
 
}
641
 
 
642
 
TEST_F(MirConnectionTest, unfocused_window_does_not_synthesise_unfocus_event_on_release)
643
 
{
644
 
    using namespace testing;
645
 
 
646
 
    MirSurfaceSpec params{nullptr, 640, 480, mir_pixel_format_abgr_8888};
647
 
    params.surface_name = __PRETTY_FUNCTION__;
648
 
 
649
 
    unfocused_received = false;
650
 
 
651
 
    MirWaitHandle *wait_handle = connection->connect("MirClientSurfaceTest", &connected_callback, nullptr);
652
 
    wait_handle->wait_for_all();
653
 
 
654
 
    wait_handle = connection->create_surface(params, &surface_callback, nullptr);
655
 
    wait_handle->wait_for_all();
656
 
 
657
 
    surface->handle_event(*mev::make_event(mf::SurfaceId{surface->id()}, mir_surface_attrib_focus, mir_surface_unfocused));
658
 
 
659
 
    surface->set_event_handler(&surface_event_callback, nullptr);
660
 
 
661
 
    wait_handle = connection->release_surface(surface, &surface_callback, nullptr);
662
 
    wait_handle->wait_for_all();
663
 
 
664
 
    wait_handle = connection->disconnect();
665
 
    wait_handle->wait_for_all();
666
 
 
667
 
    EXPECT_FALSE(unfocused_received);
668
 
}
669
 
 
670
596
namespace
671
597
{
672
598
 
932
858
    params->set_buffer_usage(usage);
933
859
    params->set_pixel_format(format);
934
860
    EXPECT_CALL(*mock_channel, allocate_buffers(BufferAllocationMatches(mp_alloc)));
935
 
    EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, nullptr, size, format, usage, nullptr, nullptr));
 
861
    EXPECT_CALL(*mock_buffer_allocator, expect_buffer(_, connection.get(), size, format, usage, nullptr, nullptr));
936
862
 
937
863
    connection->allocate_buffer(size, format, usage, nullptr, nullptr);
938
864
}
940
866
TEST_F(MirConnectionTest, can_release_buffer_from_connection)
941
867
{
942
868
    int buffer_id = 1320;
 
869
    testing::NiceMock<mtd::MockMirBuffer> mock_buffer;
 
870
    ON_CALL(mock_buffer, valid())
 
871
        .WillByDefault(Return(true)); 
 
872
    ON_CALL(mock_buffer, rpc_id())
 
873
        .WillByDefault(Return(buffer_id)); 
943
874
    mp::BufferRelease release_msg;
944
875
    auto released_buffer = release_msg.add_buffers();
945
876
    released_buffer->set_buffer_id(buffer_id);
946
877
 
947
878
    EXPECT_CALL(*mock_channel, release_buffers(BufferReleaseMatches(release_msg)));
948
879
 
949
 
    connection->release_buffer(buffer_id);
 
880
    connection->release_buffer(&mock_buffer);
950
881
}