Mir

Merge lp:~kdub/mir/fix-1342029 into lp:mir

Proposed by Kevin DuBois
Status: Merged
Approved by: Kevin DuBois
Approved revision: no longer in the source branch.
Merged at revision: 1802
Proposed branch: lp:~kdub/mir/fix-1342029
Merge into: lp:mir
Diff against target: 417 lines (+106/-42)
20 files modified
include/test/mir_test_framework/executable_path.h (+28/-0)
include/test/mir_test_framework/udev_environment.h (+0/-3)
src/server/input/xcursor_loader.cpp (+2/-1)
tests/mir_test_framework/CMakeLists.txt (+6/-0)
tests/mir_test_framework/executable_path.cpp (+40/-0)
tests/mir_test_framework/udev_environment.cpp (+3/-19)
tests/unit-tests/CMakeLists.txt (+0/-1)
tests/unit-tests/android_input/test_eventhub.cpp (+3/-3)
tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp (+1/-1)
tests/unit-tests/graphics/mesa/test_display.cpp (+1/-1)
tests/unit-tests/graphics/mesa/test_display_buffer.cpp (+1/-1)
tests/unit-tests/graphics/mesa/test_display_configuration.cpp (+1/-1)
tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp (+1/-1)
tests/unit-tests/graphics/mesa/test_drm_helper.cpp (+1/-1)
tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp (+1/-1)
tests/unit-tests/graphics/mesa/test_platform.cpp (+1/-1)
tests/unit-tests/graphics/test_display.cpp (+1/-1)
tests/unit-tests/graphics/test_graphics_platform.cpp (+1/-1)
tests/unit-tests/input/test_xcursor_loader.cpp (+13/-4)
tests/unit-tests/test_udev_wrapper.cpp (+1/-1)
To merge this branch: bzr merge lp:~kdub/mir/fix-1342029
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Review via email: mp+228470@code.launchpad.net

Commit message

correct the xcursor loader test to fail instead of segfault if it cannot find the cursor images it is looking for. Modify the test to find the cursor images from the directory the test is ran from (much like umockdev recordings) Change the scripts to install the cursor images to the proper directories when cross compiling.

fixes: lp: #1342029

Description of the change

correct the xcursor loader test to fail instead of segfault if it cannot find the cursor images it is looking for. Modify the test to find the cursor images from the directory the test is ran from (much like umockdev recordings) Change the scripts to install the cursor images to the proper directories when cross compiling.

previously, the cursor images where expected to be in a hardcoded directory based on where the code was compiled (eg, /home/kdub/source/mir/tests/mir_test_framework/testing-cursor-theme). If the images where not found in this location, the test would segfault.
Now if the image cannot be found, the test will fail instead of segfault.

fixes: lp: #1342029

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

Nit:

132 +++ tests/mir_test_framework/udev_environment.cpp

libgen.h include is not needed in this file any more.

377 + auto test_cursor_path =mir_test_framework::binary_path() + std::string("/testing-cursor-theme");

Space needed after '='

review: Approve
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

1 === added file 'include/test/mir_test_framework/binary_path.h'

I know we don't need it (there are only declarations) but it is traditional to use include guards.

~~~~

6 + * Copyright © 2013 Canonical Ltd.
...
21 + * Christopher James Halse Rogers <email address hidden>

90 + * Copyright © 2013 Canonical Ltd.
...
105 + * Christopher James Halse Rogers <email address hidden>

Really?

~~~~

27 +std::string binary_path();

I don't have a good suggestion, but even slightly out of context this function name is uninformative.

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

@Alan
Added include guards.

Corrected? copyright by adding my name to it. It feels just as funny to put my name on code I didn't write, but I guess the copyright name just applies to the file creator.

renamed to executable_path(), seemed more appropriate.

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> Corrected? copyright by adding my name to it. It feels just as funny to put my
> name on code I didn't write, but I guess the copyright name just applies to
> the file creator.

I would accept an assurance that the information is correct.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'include/test/mir_test_framework/executable_path.h'
--- include/test/mir_test_framework/executable_path.h 1970-01-01 00:00:00 +0000
+++ include/test/mir_test_framework/executable_path.h 2014-07-29 12:29:39 +0000
@@ -0,0 +1,28 @@
1/*
2 * Copyright © 2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by:
17 * Kevin DuBois <kevin.dubois@canonical.com>
18 */
19
20#ifndef MIR_TEST_FRAMEWORK_EXECUTABLE_PATH_H_
21#define MIR_TEST_FRAMEWORK_EXECUTABLE_PATH_H_
22
23#include <string>
24namespace mir_test_framework
25{
26std::string executable_path();
27}
28#endif /* MIR_TEST_FRAMEWORK_EXECUTABLE_PATH_H_ */
029
=== modified file 'include/test/mir_test_framework/udev_environment.h'
--- include/test/mir_test_framework/udev_environment.h 2014-03-26 05:48:59 +0000
+++ include/test/mir_test_framework/udev_environment.h 2014-07-29 12:29:39 +0000
@@ -25,8 +25,6 @@
25#include <umockdev.h>25#include <umockdev.h>
26#include <libudev.h>26#include <libudev.h>
2727
28namespace mir
29{
30namespace mir_test_framework28namespace mir_test_framework
31{29{
32class UdevEnvironment30class UdevEnvironment
@@ -60,6 +58,5 @@
60};58};
6159
62}60}
63}
6461
65#endif //MIR_TESTING_UDEV_ENVIRONMENT62#endif //MIR_TESTING_UDEV_ENVIRONMENT
6663
=== modified file 'src/server/input/xcursor_loader.cpp'
--- src/server/input/xcursor_loader.cpp 2014-07-22 03:26:35 +0000
+++ src/server/input/xcursor_loader.cpp 2014-07-29 12:29:39 +0000
@@ -193,7 +193,8 @@
193 }, this);193 }, this);
194}194}
195195
196std::shared_ptr<mg::CursorImage> mi::XCursorLoader::image(std::string const& cursor_name,196std::shared_ptr<mg::CursorImage> mi::XCursorLoader::image(
197 std::string const& cursor_name,
197 geom::Size const& size)198 geom::Size const& size)
198{199{
199 auto xcursor_name = xcursor_name_for_mir_cursor(cursor_name);200 auto xcursor_name = xcursor_name_for_mir_cursor(cursor_name);
200201
=== modified file 'tests/mir_test_framework/CMakeLists.txt'
--- tests/mir_test_framework/CMakeLists.txt 2014-06-10 12:28:03 +0000
+++ tests/mir_test_framework/CMakeLists.txt 2014-07-29 12:29:39 +0000
@@ -8,6 +8,7 @@
8set(8set(
9 TEST_FRAMEWORK_SRCS9 TEST_FRAMEWORK_SRCS
1010
11 executable_path.cpp
11 command_line_server_configuration.cpp12 command_line_server_configuration.cpp
12 cross_process_sync.cpp13 cross_process_sync.cpp
13 server_runner.cpp14 server_runner.cpp
@@ -58,3 +59,8 @@
58 ${CMAKE_CURRENT_SOURCE_DIR}/udev_recordings ${CMAKE_BINARY_DIR}/bin/udev_recordings59 ${CMAKE_CURRENT_SOURCE_DIR}/udev_recordings ${CMAKE_BINARY_DIR}/bin/udev_recordings
59 COMMENT "Copying umockdev recordings to build dir..."60 COMMENT "Copying umockdev recordings to build dir..."
60)61)
62add_custom_command(TARGET mir-test-framework POST_BUILD
63 COMMAND ${CMAKE_COMMAND} -E copy_directory
64 ${CMAKE_CURRENT_SOURCE_DIR}/testing-cursor-theme ${CMAKE_BINARY_DIR}/bin/testing-cursor-theme
65 COMMENT "Copying testing cursor themes to build dir..."
66)
6167
=== added file 'tests/mir_test_framework/executable_path.cpp'
--- tests/mir_test_framework/executable_path.cpp 1970-01-01 00:00:00 +0000
+++ tests/mir_test_framework/executable_path.cpp 2014-07-29 12:29:39 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright © 2013,2014 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by:
17 * Christopher James Halse Rogers <christopher.halse.rogers@canonical.com>
18 * Kevin DuBois <kevin.dubois@canonical.com>
19 */
20
21#include "mir_test_framework/executable_path.h"
22
23#include <libgen.h>
24#include <stdexcept>
25#include <boost/throw_exception.hpp>
26#include <boost/exception/errinfo_errno.hpp>
27
28std::string mir_test_framework::executable_path()
29{
30 char buf[1024];
31 auto tmp = readlink("/proc/self/exe", buf, sizeof buf);
32 if (tmp < 0)
33 BOOST_THROW_EXCEPTION(boost::enable_error_info(
34 std::runtime_error("Failed to find our executable path"))
35 << boost::errinfo_errno(errno));
36 if (tmp > static_cast<ssize_t>(sizeof(buf) - 1))
37 BOOST_THROW_EXCEPTION(std::runtime_error("Path to executable is too long!"));
38 buf[tmp] = '\0';
39 return dirname(buf);
40}
041
=== renamed directory 'tests/unit-tests/input/testing-cursor-theme' => 'tests/mir_test_framework/testing-cursor-theme'
=== modified file 'tests/mir_test_framework/udev_environment.cpp'
--- tests/mir_test_framework/udev_environment.cpp 2014-03-26 05:48:59 +0000
+++ tests/mir_test_framework/udev_environment.cpp 2014-07-29 12:29:39 +0000
@@ -18,6 +18,7 @@
18 */18 */
1919
20#include "mir_test_framework/udev_environment.h"20#include "mir_test_framework/udev_environment.h"
21#include "mir_test_framework/executable_path.h"
2122
22#include <umockdev.h>23#include <umockdev.h>
2324
@@ -34,27 +35,10 @@
34#include <boost/exception/errinfo_errno.hpp>35#include <boost/exception/errinfo_errno.hpp>
3536
3637
37namespace mtf = mir::mir_test_framework;38namespace mtf = mir_test_framework;
38
39namespace
40{
41std::string binary_path()
42{
43 char buf[1024];
44 auto tmp = readlink("/proc/self/exe", buf, sizeof buf);
45 if (tmp < 0)
46 BOOST_THROW_EXCEPTION(boost::enable_error_info(
47 std::runtime_error("Failed to find our executable path"))
48 << boost::errinfo_errno(errno));
49 if (tmp > static_cast<ssize_t>(sizeof(buf) - 1))
50 BOOST_THROW_EXCEPTION(std::runtime_error("Path to executable is too long!"));
51 buf[tmp] = '\0';
52 return dirname(buf);
53}
54}
5539
56mtf::UdevEnvironment::UdevEnvironment()40mtf::UdevEnvironment::UdevEnvironment()
57 : recordings_path(binary_path() + "/udev_recordings")41 : recordings_path(mtf::executable_path() + "/udev_recordings")
58{42{
59 testbed = umockdev_testbed_new();43 testbed = umockdev_testbed_new();
60}44}
6145
=== modified file 'tests/unit-tests/CMakeLists.txt'
--- tests/unit-tests/CMakeLists.txt 2014-07-28 16:26:39 +0000
+++ tests/unit-tests/CMakeLists.txt 2014-07-29 12:29:39 +0000
@@ -5,7 +5,6 @@
5include_directories(${DRM_INCLUDE_DIRS} ${GBM_INCLUDE_DIRS} ${UMOCKDEV_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})5include_directories(${DRM_INCLUDE_DIRS} ${GBM_INCLUDE_DIRS} ${UMOCKDEV_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR})
6# TODO: Aim to remove6# TODO: Aim to remove
7include_directories(${MIR_XCURSOR_INCLUDE_DIRECTORIES})7include_directories(${MIR_XCURSOR_INCLUDE_DIRECTORIES})
8add_definitions("-DMIR_TESTING_XCURSOR_THEME=\"${CMAKE_CURRENT_SOURCE_DIR}/input/testing-cursor-theme\"")
98
10set(9set(
11 UNIT_TEST_SOURCES10 UNIT_TEST_SOURCES
1211
=== modified file 'tests/unit-tests/android_input/test_eventhub.cpp'
--- tests/unit-tests/android_input/test_eventhub.cpp 2014-03-05 07:06:07 +0000
+++ tests/unit-tests/android_input/test_eventhub.cpp 2014-07-29 12:29:39 +0000
@@ -35,7 +35,7 @@
3535
36TEST_P(EventHubDeviceEnumerationTest, ScansOnConstruction)36TEST_P(EventHubDeviceEnumerationTest, ScansOnConstruction)
37{37{
38 mir::mir_test_framework::UdevEnvironment env;38 mir_test_framework::UdevEnvironment env;
39 env.add_standard_device(GetParam());39 env.add_standard_device(GetParam());
4040
41 auto hub = android::sp<android::EventHub>{new android::EventHub{mir::report::null_input_report()}};41 auto hub = android::sp<android::EventHub>{new android::EventHub{mir::report::null_input_report()}};
@@ -54,7 +54,7 @@
5454
55TEST_P(EventHubDeviceEnumerationTest, GeneratesDeviceAddedOnHotplug)55TEST_P(EventHubDeviceEnumerationTest, GeneratesDeviceAddedOnHotplug)
56{56{
57 mir::mir_test_framework::UdevEnvironment env;57 mir_test_framework::UdevEnvironment env;
5858
59 auto hub = android::sp<android::EventHub>{new android::EventHub{mir::report::null_input_report()}};59 auto hub = android::sp<android::EventHub>{new android::EventHub{mir::report::null_input_report()}};
6060
@@ -80,7 +80,7 @@
8080
81TEST_P(EventHubDeviceEnumerationTest, GeneratesDeviceRemovedOnHotunplug)81TEST_P(EventHubDeviceEnumerationTest, GeneratesDeviceRemovedOnHotunplug)
82{82{
83 mir::mir_test_framework::UdevEnvironment env;83 mir_test_framework::UdevEnvironment env;
84 env.add_standard_device(GetParam());84 env.add_standard_device(GetParam());
8585
86 auto hub = android::sp<android::EventHub>{new android::EventHub{mir::report::null_input_report()}};86 auto hub = android::sp<android::EventHub>{new android::EventHub{mir::report::null_input_report()}};
8787
=== modified file 'tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp'
--- tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp 2014-06-06 07:56:34 +0000
+++ tests/unit-tests/graphics/mesa/test_buffer_allocator.cpp 2014-07-29 12:29:39 +0000
@@ -42,7 +42,7 @@
42namespace mgm = mir::graphics::mesa;42namespace mgm = mir::graphics::mesa;
43namespace geom = mir::geometry;43namespace geom = mir::geometry;
44namespace mtd = mir::test::doubles;44namespace mtd = mir::test::doubles;
45namespace mtf = mir::mir_test_framework;45namespace mtf = mir_test_framework;
4646
47class MesaBufferAllocatorTest : public ::testing::Test47class MesaBufferAllocatorTest : public ::testing::Test
48{48{
4949
=== modified file 'tests/unit-tests/graphics/mesa/test_display.cpp'
--- tests/unit-tests/graphics/mesa/test_display.cpp 2014-06-23 16:29:17 +0000
+++ tests/unit-tests/graphics/mesa/test_display.cpp 2014-07-29 12:29:39 +0000
@@ -56,7 +56,7 @@
56namespace ml=mir::logging;56namespace ml=mir::logging;
57namespace mrl=mir::report::logging;57namespace mrl=mir::report::logging;
58namespace mtd=mir::test::doubles;58namespace mtd=mir::test::doubles;
59namespace mtf=mir::mir_test_framework;59namespace mtf=mir_test_framework;
60namespace mr=mir::report;60namespace mr=mir::report;
6161
62namespace62namespace
6363
=== modified file 'tests/unit-tests/graphics/mesa/test_display_buffer.cpp'
--- tests/unit-tests/graphics/mesa/test_display_buffer.cpp 2014-06-06 18:54:00 +0000
+++ tests/unit-tests/graphics/mesa/test_display_buffer.cpp 2014-07-29 12:29:39 +0000
@@ -38,7 +38,7 @@
38using namespace std;38using namespace std;
39using namespace mir::test;39using namespace mir::test;
40using namespace mir::test::doubles;40using namespace mir::test::doubles;
41using namespace mir::mir_test_framework;41using namespace mir_test_framework;
42using namespace mir::graphics;42using namespace mir::graphics;
43using mir::report::null_display_report;43using mir::report::null_display_report;
4444
4545
=== modified file 'tests/unit-tests/graphics/mesa/test_display_configuration.cpp'
--- tests/unit-tests/graphics/mesa/test_display_configuration.cpp 2014-06-06 07:56:34 +0000
+++ tests/unit-tests/graphics/mesa/test_display_configuration.cpp 2014-07-29 12:29:39 +0000
@@ -43,7 +43,7 @@
43namespace mgm = mir::graphics::mesa;43namespace mgm = mir::graphics::mesa;
44namespace geom = mir::geometry;44namespace geom = mir::geometry;
45namespace mtd = mir::test::doubles;45namespace mtd = mir::test::doubles;
46namespace mtf = mir::mir_test_framework;46namespace mtf = mir_test_framework;
4747
48namespace48namespace
49{49{
5050
=== modified file 'tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp'
--- tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp 2014-06-06 07:56:34 +0000
+++ tests/unit-tests/graphics/mesa/test_display_multi_monitor.cpp 2014-07-29 12:29:39 +0000
@@ -41,7 +41,7 @@
41namespace mg = mir::graphics;41namespace mg = mir::graphics;
42namespace geom = mir::geometry;42namespace geom = mir::geometry;
43namespace mtd = mir::test::doubles;43namespace mtd = mir::test::doubles;
44namespace mtf = mir::mir_test_framework;44namespace mtf = mir_test_framework;
4545
46namespace46namespace
47{47{
4848
=== modified file 'tests/unit-tests/graphics/mesa/test_drm_helper.cpp'
--- tests/unit-tests/graphics/mesa/test_drm_helper.cpp 2014-02-26 12:25:09 +0000
+++ tests/unit-tests/graphics/mesa/test_drm_helper.cpp 2014-07-29 12:29:39 +0000
@@ -28,7 +28,7 @@
28#include <gmock/gmock.h>28#include <gmock/gmock.h>
2929
30namespace mgm = mir::graphics::mesa;30namespace mgm = mir::graphics::mesa;
31namespace mtf = mir::mir_test_framework;31namespace mtf = mir_test_framework;
32namespace mtd = mir::test::doubles;32namespace mtd = mir::test::doubles;
33 33
34namespace34namespace
3535
=== modified file 'tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp'
--- tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp 2014-06-06 07:56:34 +0000
+++ tests/unit-tests/graphics/mesa/test_gbm_buffer.cpp 2014-07-29 12:29:39 +0000
@@ -41,7 +41,7 @@
41namespace mgm=mir::graphics::mesa;41namespace mgm=mir::graphics::mesa;
42namespace geom=mir::geometry;42namespace geom=mir::geometry;
43namespace mtd=mir::test::doubles;43namespace mtd=mir::test::doubles;
44namespace mtf=mir::mir_test_framework;44namespace mtf=mir_test_framework;
4545
46class GBMBufferTest : public ::testing::Test46class GBMBufferTest : public ::testing::Test
47{47{
4848
=== modified file 'tests/unit-tests/graphics/mesa/test_platform.cpp'
--- tests/unit-tests/graphics/mesa/test_platform.cpp 2014-07-23 11:08:59 +0000
+++ tests/unit-tests/graphics/mesa/test_platform.cpp 2014-07-29 12:29:39 +0000
@@ -49,7 +49,7 @@
49namespace mg = mir::graphics;49namespace mg = mir::graphics;
50namespace mgm = mir::graphics::mesa;50namespace mgm = mir::graphics::mesa;
51namespace mtd = mir::test::doubles;51namespace mtd = mir::test::doubles;
52namespace mtf = mir::mir_test_framework;52namespace mtf = mir_test_framework;
5353
54namespace54namespace
55{55{
5656
=== modified file 'tests/unit-tests/graphics/test_display.cpp'
--- tests/unit-tests/graphics/test_display.cpp 2014-06-06 18:54:00 +0000
+++ tests/unit-tests/graphics/test_display.cpp 2014-07-29 12:29:39 +0000
@@ -44,7 +44,7 @@
44namespace mg = mir::graphics;44namespace mg = mir::graphics;
45namespace mtd = mir::test::doubles;45namespace mtd = mir::test::doubles;
46#ifndef ANDROID46#ifndef ANDROID
47namespace mtf = mir::mir_test_framework;47namespace mtf = mir_test_framework;
48#endif48#endif
4949
50class DisplayTest : public ::testing::Test50class DisplayTest : public ::testing::Test
5151
=== modified file 'tests/unit-tests/graphics/test_graphics_platform.cpp'
--- tests/unit-tests/graphics/test_graphics_platform.cpp 2014-06-06 07:56:34 +0000
+++ tests/unit-tests/graphics/test_graphics_platform.cpp 2014-07-29 12:29:39 +0000
@@ -42,7 +42,7 @@
42namespace mtd = mir::test::doubles;42namespace mtd = mir::test::doubles;
43namespace mo = mir::options;43namespace mo = mir::options;
44#ifndef ANDROID44#ifndef ANDROID
45namespace mtf = mir::mir_test_framework;45namespace mtf = mir_test_framework;
46#endif46#endif
4747
48class GraphicsPlatform : public ::testing::Test48class GraphicsPlatform : public ::testing::Test
4949
=== modified file 'tests/unit-tests/input/test_xcursor_loader.cpp'
--- tests/unit-tests/input/test_xcursor_loader.cpp 2014-06-19 23:40:22 +0000
+++ tests/unit-tests/input/test_xcursor_loader.cpp 2014-07-29 12:29:39 +0000
@@ -19,6 +19,7 @@
19#include "src/server/input/xcursor_loader.h"19#include "src/server/input/xcursor_loader.h"
2020
21#include "mir/graphics/cursor_image.h"21#include "mir/graphics/cursor_image.h"
22#include "mir_test_framework/executable_path.h"
2223
23#include <mir_toolkit/common.h>24#include <mir_toolkit/common.h>
2425
@@ -55,6 +56,12 @@
55 return raw_argb_is_only_pixel(raw_argb, size, pixel);56 return raw_argb_is_only_pixel(raw_argb, size, pixel);
56}57}
5758
59MATCHER(HasLoaded, "cursor image has loaded and is not nullptr."\
60 " Test expects cursor images to be installed to the directory the test is ran from")
61{
62 return arg != nullptr;
63}
64
58MATCHER(IsSolidRed, "")65MATCHER(IsSolidRed, "")
59{66{
60 return cursor_image_is_solid_color(arg, 0xffff0000);67 return cursor_image_is_solid_color(arg, 0xffff0000);
@@ -81,10 +88,8 @@
81 char const* old = getenv("XCURSOR_PATH");88 char const* old = getenv("XCURSOR_PATH");
82 if (old)89 if (old)
83 old_xcursor_path = strdup(old);90 old_xcursor_path = strdup(old);
84 setenv("XCURSOR_PATH",91 auto test_cursor_path =mir_test_framework::executable_path() + std::string("/testing-cursor-theme");
85 // Defined by CMake92 setenv("XCURSOR_PATH", test_cursor_path.c_str(), 1);
86 MIR_TESTING_XCURSOR_THEME,
87 1);
88}93}
8994
90void restore_xcursor_path()95void restore_xcursor_path()
@@ -109,6 +114,9 @@
109 auto blue_image = loader.image("blue", size);114 auto blue_image = loader.image("blue", size);
110 auto green_image = loader.image("green", size);115 auto green_image = loader.image("green", size);
111116
117 ASSERT_THAT(red_image, HasLoaded());
118 ASSERT_THAT(green_image, HasLoaded());
119 ASSERT_THAT(blue_image, HasLoaded());
112 EXPECT_THAT(red_image, IsSolidRed());120 EXPECT_THAT(red_image, IsSolidRed());
113 EXPECT_THAT(green_image, IsSolidGreen());121 EXPECT_THAT(green_image, IsSolidGreen());
114 EXPECT_THAT(blue_image, IsSolidBlue());122 EXPECT_THAT(blue_image, IsSolidBlue());
@@ -136,6 +144,7 @@
136144
137 // The testing theme uses a solid black image for the "arrow" symbolic145 // The testing theme uses a solid black image for the "arrow" symbolic
138 // name.146 // name.
147 ASSERT_THAT(arrow_image, HasLoaded());
139 EXPECT_THAT(arrow_image, IsSolidBlack());148 EXPECT_THAT(arrow_image, IsSolidBlack());
140 149
141 restore_xcursor_path();150 restore_xcursor_path();
142151
=== modified file 'tests/unit-tests/test_udev_wrapper.cpp'
--- tests/unit-tests/test_udev_wrapper.cpp 2014-03-13 07:47:55 +0000
+++ tests/unit-tests/test_udev_wrapper.cpp 2014-07-29 12:29:39 +0000
@@ -31,7 +31,7 @@
31#include <libudev.h>31#include <libudev.h>
32#include <poll.h>32#include <poll.h>
3333
34namespace mtf=mir::mir_test_framework;34namespace mtf=mir_test_framework;
3535
36namespace36namespace
37{37{

Subscribers

People subscribed via source and target branches