./ 0000755 0000156 0000165 00000000000 12677054331 011105 5 ustar jenkins jenkins ./cmake/ 0000755 0000156 0000165 00000000000 12677054330 012164 5 ustar jenkins jenkins ./cmake/modules/ 0000755 0000156 0000165 00000000000 12677054330 013634 5 ustar jenkins jenkins ./cmake/modules/QmlTest.cmake 0000644 0000156 0000165 00000017414 12677054330 016236 0 ustar jenkins jenkins # add_qml_test(path component_name [NO_ADD_TEST] [NO_TARGETS]
# [TARGETS target1 [target2 [...]]]
# [IMPORT_PATHS import_path1 [import_path2 [...]]
# [PROPERTIES prop1 value1 [prop2 value2 [...]]])
#
# NO_ADD_TEST will prevent adding the test to the "test" target
# NO_TARGETS will prevent adding the test to any targets
# TARGETS lists the targets the test should be added to
# IMPORT_PATHS will pass those paths to qmltestrunner as "-import" arguments
# PROPERTIES will be set on the target and test target. See CMake's set_target_properties()
#
# Two targets will be created:
# - testComponentName - Runs the test with qmltestrunner
# - tryComponentName - Runs the test with uqmlscene, for manual interaction
#
# To change/set a default value for the whole test suite, prior to calling add_qml_test, set:
# qmltest_DEFAULT_NO_ADD_TEST (default: FALSE)
# qmltest_DEFAULT_TARGETS
# qmltest_DEFAULT_IMPORT_PATHS
# qmltest_DEFAULT_PROPERTIES
find_program(qmltestrunner_exe qmltestrunner)
if(NOT qmltestrunner_exe)
msg(FATAL_ERROR "Could not locate qmltestrunner.")
endif()
set(qmlscene_exe ${CMAKE_BINARY_DIR}/tests/uqmlscene/uqmlscene)
macro(add_manual_qml_test SUBPATH COMPONENT_NAME)
set(options NO_ADD_TEST NO_TARGETS)
set(multi_value_keywords IMPORT_PATHS TARGETS PROPERTIES ENVIRONMENT)
cmake_parse_arguments(qmltest "${options}" "" "${multi_value_keywords}" ${ARGN})
set(qmlscene_TARGET try${COMPONENT_NAME})
set(qmltest_FILE ${SUBPATH}/tst_${COMPONENT_NAME})
set(qmlscene_imports "")
if(NOT "${qmltest_IMPORT_PATHS}" STREQUAL "")
foreach(IMPORT_PATH ${qmltest_IMPORT_PATHS})
list(APPEND qmlscene_imports "-I")
list(APPEND qmlscene_imports ${IMPORT_PATH})
endforeach(IMPORT_PATH)
elseif(NOT "${qmltest_DEFAULT_IMPORT_PATHS}" STREQUAL "")
foreach(IMPORT_PATH ${qmltest_DEFAULT_IMPORT_PATHS})
list(APPEND qmlscene_imports "-I")
list(APPEND qmlscene_imports ${IMPORT_PATH})
endforeach(IMPORT_PATH)
endif()
set(qmlscene_command
env ${qmltest_ENVIRONMENT}
${qmlscene_exe} ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
${qmlscene_imports}
)
add_custom_target(${qmlscene_TARGET} ${qmlscene_command})
endmacro(add_manual_qml_test)
macro(add_qml_benchmark SUBPATH COMPONENT_NAME ITERATIONS)
add_qml_test_internal(${SUBPATH} ${COMPONENT_NAME} ${ITERATIONS} ${ARGN})
endmacro(add_qml_benchmark)
macro(add_qml_test SUBPATH COMPONENT_NAME)
add_qml_test_internal(${SUBPATH} ${COMPONENT_NAME} 0 ${ARGN})
endmacro(add_qml_test)
macro(add_qml_test_internal SUBPATH COMPONENT_NAME ITERATIONS)
set(options NO_ADD_TEST NO_TARGETS)
set(multi_value_keywords IMPORT_PATHS TARGETS PROPERTIES ENVIRONMENT)
cmake_parse_arguments(qmltest "${options}" "" "${multi_value_keywords}" ${ARGN})
set(qmltest_TARGET test${COMPONENT_NAME})
set(qmltest_xvfb_TARGET xvfbtest${COMPONENT_NAME})
set(qmltest_FILE ${SUBPATH}/tst_${COMPONENT_NAME})
set(qmltestrunner_imports "")
if(NOT "${qmltest_IMPORT_PATHS}" STREQUAL "")
foreach(IMPORT_PATH ${qmltest_IMPORT_PATHS})
list(APPEND qmltestrunner_imports "-import")
list(APPEND qmltestrunner_imports ${IMPORT_PATH})
endforeach(IMPORT_PATH)
elseif(NOT "${qmltest_DEFAULT_IMPORT_PATHS}" STREQUAL "")
foreach(IMPORT_PATH ${qmltest_DEFAULT_IMPORT_PATHS})
list(APPEND qmltestrunner_imports "-import")
list(APPEND qmltestrunner_imports ${IMPORT_PATH})
endforeach(IMPORT_PATH)
endif()
string(TOLOWER "${CMAKE_GENERATOR}" cmake_generator_lower)
if(cmake_generator_lower STREQUAL "unix makefiles")
set(function_ARGS $(FUNCTION))
else()
set(function_ARGS "")
endif()
if (${ITERATIONS} GREATER 0)
set(ITERATIONS_STRING "-iterations" ${ITERATIONS})
else()
set(ITERATIONS_STRING "")
endif()
set(qmltest_command
env ${qmltest_ENVIRONMENT}
${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
${qmltestrunner_imports}
${ITERATIONS_STRING}
-o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
-o -,txt
${function_ARGS}
)
find_program( HAVE_GCC gcc )
if (NOT ${HAVE_GCC} STREQUAL "")
exec_program( gcc ARGS "-dumpmachine" OUTPUT_VARIABLE ARCH_TRIPLET )
set(LD_PRELOAD_PATH "LD_PRELOAD=/usr/lib/${ARCH_TRIPLET}/mesa/libGL.so.1")
endif()
set(qmltest_xvfb_command
env ${qmltest_ENVIRONMENT} ${LD_PRELOAD_PATH}
xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum
${qmltestrunner_exe} -input ${CMAKE_CURRENT_SOURCE_DIR}/${qmltest_FILE}.qml
${qmltestrunner_imports}
-o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
-o -,txt
${function_ARGS}
)
add_qmltest_target(${qmltest_TARGET} "${qmltest_command}" TRUE ${qmltest_NO_ADD_TEST})
add_qmltest_target(${qmltest_xvfb_TARGET} "${qmltest_xvfb_command}" ${qmltest_NO_TARGETS} TRUE)
add_manual_qml_test(${SUBPATH} ${COMPONENT_NAME} ${ARGN})
endmacro(add_qml_test_internal)
macro(add_binary_qml_test CLASS_NAME LD_PATH DEPS)
set(testCommand
LD_LIBRARY_PATH=${LD_PATH}
${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
-o ${CMAKE_BINARY_DIR}/${CLASSNAME}Test.xml,xunitxml
-o -,txt)
add_qmltest_target(test${CLASS_NAME} "${testCommand}" FALSE TRUE)
add_dependencies(test${CLASS_NAME} ${CLASS_NAME}TestExec ${DEPS})
find_program( HAVE_GCC gcc )
if (NOT ${HAVE_GCC} STREQUAL "")
exec_program( gcc ARGS "-dumpmachine" OUTPUT_VARIABLE ARCH_TRIPLET )
set(LD_PRELOAD_PATH "LD_PRELOAD=/usr/lib/${ARCH_TRIPLET}/mesa/libGL.so.1")
endif()
set(xvfbtestCommand
${LD_PRELOAD_PATH}
LD_LIBRARY_PATH=${LD_PATH}
xvfb-run --server-args "-screen 0 1024x768x24" --auto-servernum
${CMAKE_CURRENT_BINARY_DIR}/${CLASS_NAME}TestExec
-o ${CMAKE_BINARY_DIR}/${CLASS_NAME}Test.xml,xunitxml
-o -,txt)
add_qmltest_target(xvfbtest${CLASS_NAME} "${xvfbtestCommand}" FALSE TRUE)
add_dependencies(qmluitests xvfbtest${CLASS_NAME})
endmacro(add_binary_qml_test)
macro(add_qmltest_target qmltest_TARGET qmltest_command qmltest_NO_TARGETS qmltest_NO_ADD_TEST)
add_custom_target(${qmltest_TARGET} ${qmltest_command})
if(NOT "${qmltest_PROPERTIES}" STREQUAL "")
set_target_properties(${qmltest_TARGET} PROPERTIES ${qmltest_PROPERTIES})
elseif(NOT "${qmltest_DEFAULT_PROPERTIES}" STREQUAL "")
set_target_properties(${qmltest_TARGET} PROPERTIES ${qmltest_DEFAULT_PROPERTIES})
endif()
if("${qmltest_NO_ADD_TEST}" STREQUAL FALSE AND NOT "${qmltest_DEFAULT_NO_ADD_TEST}" STREQUAL "TRUE")
add_test(${qmltest_TARGET} ${qmltest_command})
if(NOT "${qmltest_UNPARSED_ARGUMENTS}" STREQUAL "")
set_tests_properties(${qmltest_TARGET} PROPERTIES ${qmltest_PROPERTIES})
elseif(NOT "${qmltest_DEFAULT_PROPERTIES}" STREQUAL "")
set_tests_properties(${qmltest_TARGET} PROPERTIES ${qmltest_DEFAULT_PROPERTIES})
endif()
endif("${qmltest_NO_ADD_TEST}" STREQUAL FALSE AND NOT "${qmltest_DEFAULT_NO_ADD_TEST}" STREQUAL "TRUE")
if("${qmltest_NO_TARGETS}" STREQUAL "FALSE")
if(NOT "${qmltest_TARGETS}" STREQUAL "")
foreach(TARGET ${qmltest_TARGETS})
add_dependencies(${TARGET} ${qmltest_TARGET})
endforeach(TARGET)
elseif(NOT "${qmltest_DEFAULT_TARGETS}" STREQUAL "")
foreach(TARGET ${qmltest_DEFAULT_TARGETS})
add_dependencies(${TARGET} ${qmltest_TARGET})
endforeach(TARGET)
endif()
endif("${qmltest_NO_TARGETS}" STREQUAL "FALSE")
endmacro(add_qmltest_target)
./cmake/modules/FindGLESv2.cmake 0000644 0000156 0000165 00000001573 12677054330 016447 0 ustar jenkins jenkins # - Try to find GLESv2
# Once done this will define
# GLESv2_FOUND - System has GLESv2
# GLESv2_INCLUDE_DIRS - The GLESv2 include directories
# GLESv2_LIBRARIES - The libraries needed to use GLESv2
find_package(PkgConfig)
pkg_check_modules(PC_GLESv2 QUIET glesv2)
find_path(GLESv2_INCLUDE_DIR GLES2/gl2.h
HINTS ${PC_GLESv2_INCLUDEDIR} ${PC_GLESv2_INCLUDE_DIRS})
find_library(GLESv2_LIBRARY GLESv2
HINTS ${PC_GLESv2_LIBDIR} ${PC_GLESv2_LIBRARY_DIRS})
set(GLESv2_LIBRARIES ${GLESv2_LIBRARY})
set(GLESv2_INCLUDE_DIRS ${GLESv2_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set GLESv2_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(GLESv2 DEFAULT_MSG
GLESv2_LIBRARY GLESv2_INCLUDE_DIR)
mark_as_advanced(GLESv2_INCLUDE_DIR GLESv2_LIBRARY)
./cmake/modules/autopilot.cmake 0000644 0000156 0000165 00000001535 12677054330 016662 0 ustar jenkins jenkins add_custom_target(autopilot)
function(declare_autopilot_test TEST_NAME TEST_SUITE WORKING_DIR)
add_custom_target(autopilot-${TEST_NAME}
COMMAND LANG=C UBUNTU_ICON_THEME=ubuntu-mobile QML2_IMPORT_PATH=${QTMIR_INSTALL_QML}/mocks python3 -m autopilot.run run ${TEST_SUITE}
WORKING_DIRECTORY ${WORKING_DIR}
DEPENDS fake_install
)
add_custom_target(fake_install
COMMAND cmake --build ${CMAKE_BINARY_DIR} --target install
)
add_dependencies(autopilot autopilot-${TEST_NAME})
add_custom_target(autopilot2-${TEST_NAME}
COMMAND LANG=C UBUNTU_ICON_THEME=ubuntu-mobile QML2_IMPORT_PATH=${QTMIR_INSTALL_QML}/mocks python2 -m autopilot.run run ${TEST_SUITE}
WORKING_DIRECTORY ${WORKING_DIR}
DEPENDS fake_install
)
add_dependencies(autopilot autopilot2-${TEST_NAME})
endfunction()
./cmake/modules/UseLttngGenTp.cmake 0000644 0000156 0000165 00000001315 12677054330 017341 0 ustar jenkins jenkins cmake_minimum_required(VERSION 2.6)
if(POLICY CMP0011)
cmake_policy(SET CMP0011 NEW)
endif(POLICY CMP0011)
find_program(LTTNG_GEN_TP NAMES lttng-gen-tp DOC "lttng-gen-tp executable")
if(NOT LTTNG_GEN_TP)
message(FATAL_ERROR "Excutable lttng-gen-top not found")
endif()
function(add_lttng_gen_tp)
set(_one_value NAME)
cmake_parse_arguments (arg "" "${_one_value}" "" ${ARGN})
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${arg_NAME}.h" "${CMAKE_CURRENT_BINARY_DIR}/${arg_NAME}.c"
COMMAND "${LTTNG_GEN_TP}"
-o "${arg_NAME}.h"
-o "${arg_NAME}.c"
"${CMAKE_CURRENT_SOURCE_DIR}/${arg_NAME}.tp"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS "${arg_NAME}.tp"
)
endfunction(add_lttng_gen_tp) ./cmake/modules/QmlPlugins.cmake 0000644 0000156 0000165 00000012652 12677054330 016737 0 ustar jenkins jenkins # If you need to override the qmlplugindump binary, create the qmlplugin executable
# target before loading this plugin.
if(NOT TARGET qmlplugindump)
find_program(qmlplugindump_exe qmlplugindump)
if(NOT qmlplugindump_exe)
msg(FATAL_ERROR "Could not locate qmlplugindump.")
endif()
add_executable(qmlplugindump IMPORTED)
set_target_properties(qmlplugindump PROPERTIES IMPORTED_LOCATION ${qmlplugindump_exe})
endif()
#
# A custom target for building the qmltypes files manually.
#
if (NOT TARGET qmltypes)
add_custom_target(qmltypes)
endif()
# Creates a target for copying resource files into build dir and optionally installing them.
#
# Files will be copied into ${BINARY_DIR}/${path} or ${CMAKE_CURRENT_BINARY_DIR} and installed
# into ${DESTINATION}/${path}.
#
# Resource file names are matched against {*.{qml,js,jpg,png,sci,svg},qmldir}.
#
# export_qmlfiles(plugin path
# [SEARCH_PATH path] # Path to search for resources in (defaults to ${CMAKE_CURRENT_SOURCE_DIR})
# [BINARY_DIR path]
# [DESTINATION path]
# [TARGET_PREFIX string] # Will be prefixed to the target name
# )
#
# Created target:
# - ${TARGET_PREFIX}${plugin}-qmlfiles - Copies resources into the binary dir.
macro(export_qmlfiles PLUGIN PATH)
set(single SEARCH_PATH BINARY_DIR DESTINATION TARGET_PREFIX)
cmake_parse_arguments(QMLFILES "" "${single}" "" ${ARGN})
if(NOT QMLFILES_SEARCH_PATH)
set(QMLFILES_SEARCH_PATH ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(QMLFILES_BINARY_DIR)
set(qmlfiles_dir ${QMLFILES_BINARY_DIR}/${PATH})
else()
set(qmlfiles_dir ${CMAKE_CURRENT_BINARY_DIR})
endif()
file(GLOB QMLFILES
${QMLFILES_SEARCH_PATH}/*.qml
${QMLFILES_SEARCH_PATH}/*.js
${QMLFILES_SEARCH_PATH}/*.jpg
${QMLFILES_SEARCH_PATH}/*.png
${QMLFILES_SEARCH_PATH}/*.sci
${QMLFILES_SEARCH_PATH}/*.svg
${QMLFILES_SEARCH_PATH}/*.qmltypes
${QMLFILES_SEARCH_PATH}/qmldir
)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${qmlfiles_dir})
# copy the files
add_custom_target(${QMLFILES_TARGET_PREFIX}${PLUGIN}-qmlfiles ALL
COMMAND cp ${QMLFILES} ${qmlfiles_dir}
DEPENDS ${QMLFILES}
SOURCES ${QMLFILES}
)
if(QMLFILES_DESTINATION)
# install the qmlfiles file.
install(FILES ${QMLFILES}
DESTINATION ${QMLFILES_DESTINATION}/${PATH}
)
endif()
endmacro()
# Creates a target for generating the typeinfo file for a QML plugin and/or installs the plugin
# targets.
#
# Files will be copied into ${BINARY_DIR}/${path} or ${CMAKE_CURRENT_BINARY_DIR} and installed
# into ${DESTINATION}/${path}. If you don't pass BINARY_DIR, it's assumed that current source
# path ends with ${path}.
#
# The generated file will be named after the last segment of the plugin name, e.g. Foo.qmltypes.
#
# export_qmlplugin(plugin version path
# [BINARY_DIR path]
# [DESTINATION path]
# [TARGET_PREFIX string] # Will be prefixed to the target name
# [ENVIRONMENT string] # Will be added to qmlplugindump's env
# [TARGETS target1 [target2 ...]] # Targets to depend on and install (e.g. the plugin shared object)
# [NO_TYPES] # Do not create the qmltypes target
# )
#
# Created target:
# - ${TARGET_PREFIX}${plugin}-qmltypes - Generates the qmltypes file in the source dir.
# It will be made a dependency of the "qmltypes" target.
macro(export_qmlplugin PLUGIN VERSION PATH)
set(options NO_TYPES)
set(single BINARY_DIR DESTINATION TARGET_PREFIX ENVIRONMENT)
set(multi TARGETS)
cmake_parse_arguments(QMLPLUGIN "${options}" "${single}" "${multi}" ${ARGN})
get_target_property(qmlplugindump_executable qmlplugindump LOCATION)
if(QMLPLUGIN_BINARY_DIR)
set(qmlplugin_dir ${QMLPLUGIN_BINARY_DIR}/${PATH})
else()
# Find import path to point qmlplugindump at
string(REGEX REPLACE "/${PATH}$" "" QMLPLUGIN_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(qmlplugin_dir ${CMAKE_CURRENT_BINARY_DIR})
endif()
if(NOT QMLPLUGIN_NO_TYPES)
# Relative path for the module
string(REPLACE "${CMAKE_BINARY_DIR}/" "" QMLPLUGIN_MODULE_DIR "${QMLPLUGIN_BINARY_DIR}")
# Find the last segment of the plugin name to use as qmltypes basename
string(REGEX MATCH "[^.]+$" plugin_suffix ${PLUGIN})
set(target_prefix ${QMLPLUGIN_TARGET_PREFIX}${PLUGIN})
set(qmltypes_path ${CMAKE_CURRENT_SOURCE_DIR}/${plugin_suffix}.qmltypes)
add_custom_target(${target_prefix}-qmltypes
COMMAND env ${QMLPLUGIN_ENVIRONMENT} ${qmlplugindump_executable} -notrelocatable
${PLUGIN} ${VERSION} ${QMLPLUGIN_MODULE_DIR} > ${qmltypes_path}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_dependencies(${target_prefix}-qmltypes ${target_prefix}-qmlfiles ${QMLPLUGIN_TARGETS})
add_dependencies(qmltypes ${target_prefix}-qmltypes)
endif()
set_target_properties(${QMLPLUGIN_TARGETS} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${qmlplugin_dir}
LIBRARY_OUTPUT_DIRECTORY ${qmlplugin_dir}
RUNTIME_OUTPUT_DIRECTORY ${qmlplugin_dir}
)
if (QMLPLUGIN_DESTINATION)
# Install additional targets
install(TARGETS ${QMLPLUGIN_TARGETS}
DESTINATION ${QMLPLUGIN_DESTINATION}/${PATH}
)
endif()
endmacro()
./tests/ 0000755 0000156 0000165 00000000000 12677054330 012246 5 ustar jenkins jenkins ./tests/framework/ 0000755 0000156 0000165 00000000000 12677054330 014243 5 ustar jenkins jenkins ./tests/framework/mock_settings.h 0000644 0000156 0000165 00000002040 12677054330 017261 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_SETTINGS_H
#define MOCK_SETTINGS_H
#include
#include
#include
namespace qtmir
{
struct MockSettings : public qtmir::SettingsInterface
{
MockSettings();
virtual ~MockSettings();
MOCK_CONST_METHOD1(get, QVariant(const QString &));
};
} // namespace qtmir
#endif // MOCK_SETTINGS_H
./tests/framework/fake_desktopfilereader.cpp 0000644 0000156 0000165 00000004505 12677054330 021435 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "fake_desktopfilereader.h"
#include
namespace qtmir
{
FakeDesktopFileReader::FakeDesktopFileReader(const QString &appId)
: DesktopFileReader()
, m_appId(appId)
{
}
FakeDesktopFileReader::FakeDesktopFileReader()
: DesktopFileReader()
, m_appId("foo-app")
{
}
FakeDesktopFileReader::~FakeDesktopFileReader()
{
}
QString FakeDesktopFileReader::file() const { return m_appId + ".desktop"; }
QString FakeDesktopFileReader::appId() const { return m_appId; }
QString FakeDesktopFileReader::name() const { return QString(); }
QString FakeDesktopFileReader::comment() const { return QString(); }
QString FakeDesktopFileReader::icon() const { return QString(); }
QString FakeDesktopFileReader::exec() const { return QString(); }
QString FakeDesktopFileReader::path() const { return QString(); }
QString FakeDesktopFileReader::stageHint() const { return QString(); }
QString FakeDesktopFileReader::splashTitle() const { return QString(); }
QString FakeDesktopFileReader::splashImage() const { return QString(); }
QString FakeDesktopFileReader::splashShowHeader() const { return QString(); }
QString FakeDesktopFileReader::splashColor() const { return QString(); }
QString FakeDesktopFileReader::splashColorHeader() const { return QString(); }
QString FakeDesktopFileReader::splashColorFooter() const { return QString(); }
Qt::ScreenOrientations FakeDesktopFileReader::supportedOrientations() const { return Qt::PortraitOrientation; }
bool FakeDesktopFileReader::rotatesWindowContents() const { return false; }
bool FakeDesktopFileReader::isTouchApp() const { return true; }
bool FakeDesktopFileReader::loaded() const { return true; }
} // namespace qtmir
./tests/framework/fake_displayconfigurationoutput.h 0000644 0000156 0000165 00000003773 12677054330 023132 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef FAKE_DISPLAYCONFIGURATIONOUTPUT_H
#define FAKE_DISPLAYCONFIGURATIONOUTPUT_H
#include
namespace mg = mir::graphics;
namespace geom = mir::geometry;
const mg::DisplayConfigurationOutput fakeOutput1
{
mg::DisplayConfigurationOutputId{3},
mg::DisplayConfigurationCardId{2},
mg::DisplayConfigurationOutputType::dvid,
{
mir_pixel_format_abgr_8888
},
{
{geom::Size{100, 200}, 60.0},
{geom::Size{100, 200}, 59.0},
{geom::Size{150, 200}, 59.0}
},
0,
geom::Size{1111, 2222},
true,
true,
geom::Point(),
2,
mir_pixel_format_abgr_8888,
mir_power_mode_on,
mir_orientation_normal,
1.0f,
mir_form_factor_unknown
};
const mg::DisplayConfigurationOutput fakeOutput2
{
mg::DisplayConfigurationOutputId{2},
mg::DisplayConfigurationCardId{4},
mg::DisplayConfigurationOutputType::lvds,
{
mir_pixel_format_xbgr_8888
},
{
{geom::Size{800, 1200}, 90.0},
{geom::Size{1600, 2400}, 60.0},
{geom::Size{1500, 2000}, 75.0}
},
0,
geom::Size{1000, 2000},
true,
true,
geom::Point(500, 600),
2,
mir_pixel_format_xbgr_8888,
mir_power_mode_on,
mir_orientation_left,
1.0f,
mir_form_factor_unknown
};
#endif // FAKE_DISPLAYCONFIGURATIONOUTPUT_H
./tests/framework/stub_scene_surface.cpp 0000644 0000156 0000165 00000006254 12677054330 020620 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "stub_scene_surface.h"
namespace mir
{
namespace test
{
namespace doubles
{
StubSceneSurface::StubSceneSurface(int fd)
: channel(std::make_shared(fd)), fd(fd)
{
}
StubSceneSurface::~StubSceneSurface()
{
}
std::shared_ptr StubSceneSurface::input_channel() const
{
return channel;
}
mir::input::InputReceptionMode StubSceneSurface::reception_mode() const
{
return input_mode;
}
std::string StubSceneSurface::name() const { return {}; }
mir::geometry::Point StubSceneSurface::top_left() const { return {}; }
mir::geometry::Size StubSceneSurface::client_size() const { return {};}
mir::geometry::Size StubSceneSurface::size() const { return {}; }
mir::geometry::Rectangle StubSceneSurface::input_bounds() const { return {{},{}}; }
bool StubSceneSurface::input_area_contains(mir::geometry::Point const&) const { return false; }
mir::graphics::RenderableList StubSceneSurface::generate_renderables(mir::compositor::CompositorID) const { return {};}
float StubSceneSurface::alpha() const { return 0.0f; }
MirSurfaceType StubSceneSurface::type() const { return mir_surface_type_normal; }
MirSurfaceState StubSceneSurface::state() const { return mir_surface_state_unknown; }
void StubSceneSurface::hide() {}
void StubSceneSurface::show() {}
void StubSceneSurface::move_to(const mir::geometry::Point &) {}
void StubSceneSurface::set_input_region(const std::vector &) {}
void StubSceneSurface::resize(const mir::geometry::Size &) {}
void StubSceneSurface::set_transformation(const glm::mat4 &) {}
void StubSceneSurface::set_alpha(float) {}
void StubSceneSurface::set_orientation(MirOrientation) {}
void StubSceneSurface::add_observer(const std::shared_ptr &) {}
void StubSceneSurface::remove_observer(const std::weak_ptr &) {}
void StubSceneSurface::set_reception_mode(mir::input::InputReceptionMode mode) { input_mode = mode; }
void StubSceneSurface::consume(const MirEvent *) {}
void StubSceneSurface::set_cursor_image(const std::shared_ptr &) {}
std::shared_ptr StubSceneSurface::cursor_image() const { return {}; }
bool StubSceneSurface::supports_input() const { return true; }
int StubSceneSurface::client_input_fd() const { return fd;}
int StubSceneSurface::configure(MirSurfaceAttrib, int) { return 0; }
int StubSceneSurface::query(MirSurfaceAttrib) const { return 0; }
} // namespace doubles
} // namespace test
} // namespace mir
./tests/framework/mock_prompt_session_manager.cpp 0000644 0000156 0000165 00000001617 12677054330 022543 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_prompt_session_manager.h"
namespace mir
{
namespace scene
{
MockPromptSessionManager::MockPromptSessionManager()
{
}
MockPromptSessionManager::~MockPromptSessionManager()
{
}
} // namespace scene
} // namespace mir
./tests/framework/fake_mirsurface.cpp 0000644 0000156 0000165 00000013261 12677054330 020100 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "fake_mirsurface.h"
namespace qtmir
{
FakeMirSurface::TouchEvent::TouchEvent(Qt::KeyboardModifiers mods,
const QList &points,
Qt::TouchPointStates states,
ulong timestamp)
: keyboardModifiers(mods)
, touchPoints(points)
, states(states)
, timestamp(timestamp)
{
}
FakeMirSurface::TouchEvent::~TouchEvent()
{
}
FakeMirSurface::FakeMirSurface(QObject *parent)
: MirSurfaceInterface(parent)
, m_isFirstFrameDrawn(false)
, m_isFrameDropperRunning(true)
, m_live(true)
, m_state(Mir::RestoredState)
, m_orientationAngle(Mir::Angle0)
, m_visible(true)
, m_focused(false)
{
}
FakeMirSurface::~FakeMirSurface()
{
}
Mir::Type FakeMirSurface::type() const { return Mir::NormalType; }
QString FakeMirSurface::name() const { return QString("Fake MirSurface"); }
QSize FakeMirSurface::size() const { return m_size; }
void FakeMirSurface::resize(int width, int height)
{
if (m_size.width() != width || m_size.height() != height) {
m_size.setWidth(width);
m_size.setHeight(height);
Q_EMIT sizeChanged(m_size);
}
}
void FakeMirSurface::resize(const QSize &size) { resize(size.width(), size.height()); }
Mir::State FakeMirSurface::state() const { return m_state; }
void FakeMirSurface::setState(Mir::State qmlState)
{
if (qmlState != m_state) {
m_state = qmlState;
Q_EMIT stateChanged(m_state);
}
}
bool FakeMirSurface::live() const { return m_live; }
bool FakeMirSurface::visible() const { return m_visible; }
Mir::OrientationAngle FakeMirSurface::orientationAngle() const { return m_orientationAngle; }
void FakeMirSurface::setOrientationAngle(Mir::OrientationAngle angle)
{
if (m_orientationAngle != angle) {
m_orientationAngle = angle;
Q_EMIT orientationAngleChanged(m_orientationAngle);
}
}
bool FakeMirSurface::isFirstFrameDrawn() const
{
return m_isFirstFrameDrawn;
}
void FakeMirSurface::stopFrameDropper()
{
m_isFrameDropperRunning = false;
}
void FakeMirSurface::startFrameDropper()
{
m_isFrameDropperRunning = true;
}
void FakeMirSurface::setLive(bool value)
{
if (m_live != value) {
m_live = value;
Q_EMIT liveChanged(m_live);
}
}
void FakeMirSurface::setViewVisibility(qintptr viewId, bool visible) {
if (!m_views.contains(viewId)) return;
m_views[viewId] = visible;
updateVisibility();
}
bool FakeMirSurface::isBeingDisplayed() const { return !m_views.isEmpty(); }
void FakeMirSurface::registerView(qintptr viewId)
{
m_views.insert(viewId, false);
if (m_views.count() == 1) {
Q_EMIT isBeingDisplayedChanged();
}
}
void FakeMirSurface::unregisterView(qintptr viewId)
{
m_views.remove(viewId);
if (m_views.count() == 0) {
Q_EMIT isBeingDisplayedChanged();
}
updateVisibility();
}
QSharedPointer FakeMirSurface::texture() { return QSharedPointer(); }
QSGTexture *FakeMirSurface::weakTexture() const { return nullptr; }
bool FakeMirSurface::updateTexture() { return true; }
unsigned int FakeMirSurface::currentFrameNumber() const { return 0; }
bool FakeMirSurface::numBuffersReadyForCompositor() { return 0; }
void FakeMirSurface::setFocus(bool focus) { m_focused = focus; }
void FakeMirSurface::mousePressEvent(QMouseEvent *) {}
void FakeMirSurface::mouseMoveEvent(QMouseEvent *) {}
void FakeMirSurface::mouseReleaseEvent(QMouseEvent *) {}
void FakeMirSurface::hoverEnterEvent(QHoverEvent *) {}
void FakeMirSurface::hoverLeaveEvent(QHoverEvent *) {}
void FakeMirSurface::hoverMoveEvent(QHoverEvent *) {}
void FakeMirSurface::wheelEvent(QWheelEvent *) {}
void FakeMirSurface::keyPressEvent(QKeyEvent *) {}
void FakeMirSurface::keyReleaseEvent(QKeyEvent *) {}
void FakeMirSurface::touchEvent(Qt::KeyboardModifiers mods,
const QList &points,
Qt::TouchPointStates states,
ulong timestamp)
{
m_touchesReceived.append(TouchEvent(mods, points, states, timestamp));
}
QString FakeMirSurface::appId() const { return "foo-app"; }
void FakeMirSurface::setKeymap(const QString &layout, const QString &variant)
{
Q_EMIT keymapChanged(layout, variant);
}
void FakeMirSurface::onCompositorSwappedBuffers() {}
void FakeMirSurface::drawFirstFrame()
{
if (!m_isFirstFrameDrawn) {
m_isFirstFrameDrawn = true;
Q_EMIT firstFrameDrawn();
}
}
bool FakeMirSurface::isFrameDropperRunning() const { return m_isFrameDropperRunning; }
QList &FakeMirSurface::touchesReceived() { return m_touchesReceived; }
void FakeMirSurface::updateVisibility()
{
bool newVisible = false;
QHashIterator i(m_views);
while (i.hasNext()) {
i.next();
newVisible |= i.value();
}
if (m_visible != newVisible) {
m_visible = newVisible;
Q_EMIT visibleChanged(newVisible);
}
}
} // namespace qtmir
./tests/framework/mock_main_loop.h 0000644 0000156 0000165 00000003330 12677054330 017401 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCKMAINLOOP_H
#define MOCKMAINLOOP_H
#include
#include "gmock_fixes.h"
class MockMainLoop : public mir::MainLoop
{
public:
MockMainLoop();
~MockMainLoop() noexcept;
void run() override;
void stop() override;
MOCK_METHOD2(register_signal_handler,
void(std::initializer_list,
std::function const&));
MOCK_METHOD3(register_fd_handler,
void(std::initializer_list, void const*,
std::function const&));
MOCK_METHOD1(unregister_fd_handler, void(void const*));
MOCK_METHOD2(enqueue, void(void const*, mir::ServerAction const&));
MOCK_METHOD1(pause_processing_for,void (void const*));
MOCK_METHOD1(resume_processing_for,void (void const*));
MOCK_METHOD1(create_alarm, std::unique_ptr(std::function const& callback));
MOCK_METHOD1(create_alarm, std::unique_ptr(std::shared_ptr const& callback));
};
#endif // MOCKMAINLOOP_H
./tests/framework/mock_display_configuration.cpp 0000644 0000156 0000165 00000001502 12677054330 022352 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_display_configuration.h"
MockDisplayConfiguration::MockDisplayConfiguration()
{
}
MockDisplayConfiguration::~MockDisplayConfiguration()
{
}
./tests/framework/mock_task_controller.cpp 0000644 0000156 0000165 00000006016 12677054330 021170 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_task_controller.h"
namespace qtmir
{
MockTaskController::MockTaskController()
{
using namespace ::testing;
ON_CALL(*this, primaryPidForAppId(_))
.WillByDefault(
Invoke(this, &MockTaskController::doPrimaryPidForAppId));
ON_CALL(*this, appIdHasProcessId(_, _))
.WillByDefault(
Invoke(this, &MockTaskController::doAppIdHasProcessId));
ON_CALL(*this, findDesktopFileForAppId(_))
.WillByDefault(
Invoke(this, &MockTaskController::doFindDesktopFileForAppId));
ON_CALL(*this, stop(_))
.WillByDefault(
Invoke(this, &MockTaskController::doStop));
ON_CALL(*this, start(_, _))
.WillByDefault(
Invoke(this, &MockTaskController::doStart));
ON_CALL(*this, suspend(_))
.WillByDefault(
Invoke(this, &MockTaskController::doSuspend));
ON_CALL(*this, resume(_))
.WillByDefault(
Invoke(this, &MockTaskController::doResume));
}
MockTaskController::~MockTaskController()
{
}
pid_t MockTaskController::doPrimaryPidForAppId(const QString &appId)
{
auto it = children.find(appId);
if (it == children.end())
return -1;
return it->pid();
}
bool MockTaskController::doAppIdHasProcessId(const QString &appId, pid_t pid)
{
auto primaryPid = primaryPidForAppId(appId);
if (primaryPid == -1)
return false;
return primaryPid == pid;
}
QFileInfo MockTaskController::doFindDesktopFileForAppId(const QString &appId) const
{
QString path = QString("/usr/share/applications/%1.desktop").arg(appId);
return QFileInfo(path);
}
bool MockTaskController::doStop(const QString &appId)
{
Q_UNUSED(appId);
return false;
}
bool MockTaskController::doStart(const QString &appId, const QStringList &args)
{
Q_UNUSED(args);
auto child = core::posix::fork([]()
{
while (true);
return core::posix::exit::Status::success;
}, core::posix::StandardStream::empty);
if (child.pid() > 0)
{
children.insert(appId, child);
return true;
}
return false;
}
bool MockTaskController::doSuspend(const QString &appId)
{
Q_UNUSED(appId);
return false;
}
bool MockTaskController::doResume(const QString &appId)
{
Q_UNUSED(appId);
return false;
}
} // namespace qtmir
./tests/framework/stub_input_channel.h 0000644 0000156 0000165 00000002236 12677054330 020303 0 ustar jenkins jenkins /*
* Copyright (C) 2013-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MIR_TEST_DOUBLES_STUB_INPUT_CHANNEL_H_
#define MIR_TEST_DOUBLES_STUB_INPUT_CHANNEL_H_
#include "mir/input/input_channel.h"
namespace mir
{
namespace test
{
namespace doubles
{
struct StubInputChannel : public input::InputChannel
{
StubInputChannel(int fd);
StubInputChannel();
virtual ~StubInputChannel();
int client_fd() const override;
int server_fd() const override;
int input_fd;
};
}
}
} // namespace mir
#endif // MIR_TEST_DOUBLES_STUB_INPUT_CHANNEL_H_
./tests/framework/mock_proc_info.h 0000644 0000156 0000165 00000002066 12677054330 017407 0 ustar jenkins jenkins /*
* Copyright (C) 2014-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_PROC_INFO_H
#define MOCK_PROC_INFO_H
#include
#include
namespace qtmir {
struct MockProcInfo : public qtmir::ProcInfo
{
MockProcInfo();
virtual ~MockProcInfo();
MOCK_METHOD1(command_line, QByteArray(pid_t));
std::unique_ptr commandLine(pid_t pid);
};
} // namespace qtmir
#endif // MOCK_PROC_INFO_H
./tests/framework/mock_gl_display_buffer.cpp 0000644 0000156 0000165 00000002063 12677054330 021441 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_gl_display_buffer.h"
MockGLDisplayBuffer::MockGLDisplayBuffer()
{
using namespace testing;
ON_CALL(*this, view_area())
.WillByDefault(Return(mir::geometry::Rectangle{{0,0},{0,0}}));
ON_CALL(*this, native_display_buffer())
.WillByDefault(Return(dynamic_cast(this)));
}
MockGLDisplayBuffer::~MockGLDisplayBuffer()
{
}
./tests/framework/fake_session.cpp 0000644 0000156 0000165 00000006337 12677054330 017431 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "fake_session.h"
namespace qtmir
{
FakeSession::FakeSession()
: SessionInterface(0)
, m_application(nullptr)
, m_state(Starting)
{
}
FakeSession::~FakeSession()
{
}
void FakeSession::release() {}
QString FakeSession::name() const { return QString("foo-session"); }
unity::shell::application::ApplicationInfoInterface *FakeSession::application() const { return m_application; }
MirSurfaceInterface *FakeSession::lastSurface() const { return nullptr; }
const ObjectListModel *FakeSession::surfaces() const { return nullptr; }
SessionInterface *FakeSession::parentSession() const { return nullptr; }
SessionModel *FakeSession::childSessions() const { return nullptr; }
SessionInterface::State FakeSession::state() const { return m_state; }
bool FakeSession::fullscreen() const { return false; }
bool FakeSession::live() const { return true; }
std::shared_ptr FakeSession::session() const { return nullptr; }
void FakeSession::registerSurface(MirSurfaceInterface *) {}
void FakeSession::removeSurface(MirSurfaceInterface *) {}
void FakeSession::setApplication(unity::shell::application::ApplicationInfoInterface *app)
{
if (m_application != app) {
m_application = app;
Q_EMIT applicationChanged(m_application);
}
}
void FakeSession::suspend()
{
if (m_state == Running) {
setState(Suspending);
}
}
void FakeSession::resume()
{
if (m_state == Suspending || m_state == Suspended) {
setState(Running);
}
}
void FakeSession::stop()
{
setState(Stopped);
}
void FakeSession::close() {}
void FakeSession::addChildSession(SessionInterface *) {}
void FakeSession::insertChildSession(uint, SessionInterface *) {}
void FakeSession::removeChildSession(SessionInterface *) {}
void FakeSession::foreachChildSession(std::function) const {}
std::shared_ptr FakeSession::activePromptSession() const
{
return std::shared_ptr();
}
void FakeSession::foreachPromptSession(std::function &)>) const {}
void FakeSession::setFullscreen(bool) {}
void FakeSession::setLive(const bool) {}
void FakeSession::appendPromptSession(const std::shared_ptr &) {}
void FakeSession::removePromptSession(const std::shared_ptr &) {}
void FakeSession::setState(SessionInterface::State state)
{
if (m_state != state) {
m_state = state;
Q_EMIT stateChanged(m_state);
}
}
} // namespace qtmir
./tests/framework/mock_mir_session.h 0000644 0000156 0000165 00000006166 12677054330 017770 0 ustar jenkins jenkins /*
* Copyright (C) 2014-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_MIR_SCENE_SESSION_H
#define MOCK_MIR_SCENE_SESSION_H
#include
#include
#include
#include
#include
namespace mir {
namespace scene {
struct MockSession : public Session
{
MockSession();
MockSession(std::string const& sessionName, pid_t processId);
virtual ~MockSession();
std::string name() const override;
pid_t process_id() const override;
MOCK_METHOD0(force_requests_to_complete, void());
MOCK_CONST_METHOD0(default_surface, std::shared_ptr());
MOCK_CONST_METHOD1(get_surface, std::shared_ptr(frontend::SurfaceId));
MOCK_CONST_METHOD1(surface, std::shared_ptr(frontend::SurfaceId));
MOCK_METHOD1(take_snapshot, void(SnapshotCallback const&));
MOCK_METHOD1(set_lifecycle_state, void(MirLifecycleState));
MOCK_METHOD2(create_surface,
frontend::SurfaceId(SurfaceCreationParameters const&,
std::shared_ptr const&));
MOCK_METHOD1(destroy_surface, void (frontend::SurfaceId));
MOCK_METHOD1(destroy_surface, void (std::weak_ptr const& surface));
MOCK_METHOD0(hide, void());
MOCK_METHOD0(show, void());
MOCK_METHOD1(send_display_config, void(graphics::DisplayConfiguration const&));
MOCK_METHOD3(configure_surface, int(frontend::SurfaceId, MirSurfaceAttrib, int));
void start_prompt_session() override;
void stop_prompt_session() override;
void suspend_prompt_session() override;
void resume_prompt_session() override;
std::shared_ptr surface_after(std::shared_ptr const&) const override;
MOCK_CONST_METHOD1(get_buffer_stream, std::shared_ptr(frontend::BufferStreamId));
MOCK_METHOD1(destroy_buffer_stream, void(frontend::BufferStreamId));
MOCK_METHOD1(create_buffer_stream, frontend::BufferStreamId(graphics::BufferProperties const&));
void configure_streams(Surface&, std::vector const&) override;;
MOCK_METHOD1(send_input_device_change, void(std::vector> const&));
//void send_input_device_change(std::vector> const& devices) = 0;
private:
std::string m_sessionName;
pid_t m_sessionId;
};
} // namespace scene
} // namespace mir
#endif // MOCK_MIR_SCENE_SESSION_H
./tests/framework/mock_proc_info.cpp 0000644 0000156 0000165 00000002074 12677054330 017741 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_proc_info.h"
namespace qtmir
{
MockProcInfo::MockProcInfo()
{
using namespace ::testing;
ON_CALL(*this, command_line(_)).WillByDefault(Return(QByteArray()));
}
MockProcInfo::~MockProcInfo()
{
}
std::unique_ptr MockProcInfo::commandLine(pid_t pid)
{
return std::unique_ptr(new CommandLine{command_line(pid)});
}
} // namespace qtmir
./tests/framework/mock_prompt_session.cpp 0000644 0000156 0000165 00000001553 12677054330 021050 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_prompt_session.h"
namespace mir
{
namespace scene
{
MockPromptSession::MockPromptSession()
{
}
MockPromptSession::~MockPromptSession()
{
}
} // namespace scene
} // namespace mir
./tests/framework/mock_surface.cpp 0000644 0000156 0000165 00000002300 12677054330 017403 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_surface.h"
namespace mir
{
namespace scene
{
MockSurface::MockSurface()
{
}
MockSurface::~MockSurface()
{
}
void MockSurface::rename(const std::string &) {}
void MockSurface::set_keymap(MirInputDeviceId,
std::string const&,
std::string const&,
std::string const&,
std::string const&)
{
}
// void MockSurface::consume(const MirEvent &event) { consume(&event); }
} // namespace scene
} // namespace mir
./tests/framework/mock_display.h 0000644 0000156 0000165 00000005065 12677054330 017100 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCKDISPLAY_H
#define MOCKDISPLAY_H
#include
#include
#include
#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 20, 0)
#include
#endif
#include
#include "gmock_fixes.h"
class MockDisplaySyncGroup : public mir::graphics::DisplaySyncGroup
{
public:
MockDisplaySyncGroup();
virtual ~MockDisplaySyncGroup();
MOCK_METHOD1(for_each_display_buffer, void(std::function const& f));
MOCK_METHOD0(post, void());
};
struct MockDisplay : public mir::graphics::Display
{
public:
MockDisplay();
virtual ~MockDisplay();
MOCK_METHOD1(for_each_display_sync_group, void(std::function const&));
MOCK_CONST_METHOD0(configuration, std::unique_ptr());
MOCK_METHOD1(configure, void(mir::graphics::DisplayConfiguration const&));
MOCK_METHOD2(register_configuration_change_handler,
void(mir::graphics::EventHandlerRegister&, mir::graphics::DisplayConfigurationChangeHandler const&));
MOCK_METHOD3(register_pause_resume_handlers, void(mir::graphics::EventHandlerRegister&,
mir::graphics::DisplayPauseHandler const&,
mir::graphics::DisplayResumeHandler const&));
MOCK_METHOD0(pause, void());
MOCK_METHOD0(resume, void());
MOCK_METHOD1(create_hardware_cursor, std::shared_ptr(std::shared_ptr const&));
MOCK_METHOD0(create_gl_context, std::unique_ptr());
#if MIR_SERVER_VERSION >= MIR_VERSION_NUMBER(0, 20, 0)
MOCK_METHOD2(create_virtual_output, std::unique_ptr (int width, int height));
#endif
};
#endif // MOCKDISPLAY_H
./tests/framework/mock_renderable.h 0000644 0000156 0000165 00000002554 12677054330 017536 0 ustar jenkins jenkins /*
* Copyright (C) 2014-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_MIR_GRAPHICS_RENDERABLE_H
#define MOCK_MIR_GRAPHICS_RENDERABLE_H
#include
#include
namespace mir {
namespace graphics {
struct MockRenderable : public Renderable
{
MockRenderable();
virtual ~MockRenderable();
MOCK_CONST_METHOD0(id, ID());
MOCK_CONST_METHOD0(buffer, std::shared_ptr());
MOCK_CONST_METHOD0(alpha_enabled, bool());
MOCK_CONST_METHOD0(screen_position, geometry::Rectangle());
MOCK_CONST_METHOD0(alpha, float() );
MOCK_CONST_METHOD0(transformation, glm::mat4());
MOCK_CONST_METHOD0(shaped, bool());
};
} // namespace graphics
} // namespace mir
#endif // MOCK_MIR_GRAPHICS_RENDERABLE_H
./tests/framework/mock_shared_wakelock.h 0000644 0000156 0000165 00000002545 12677054330 020561 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_SHARED_WAKELOCK_H
#define MOCK_SHARED_WAKELOCK_H
#include
#include
namespace qtmir
{
class MockSharedWakelock : public qtmir::SharedWakelock
{
public:
MockSharedWakelock(const QDBusConnection& /*connection*/= QDBusConnection::systemBus());
virtual ~MockSharedWakelock();
MOCK_CONST_METHOD0(enabled, bool());
MOCK_METHOD1(acquire, void(const QObject *));
MOCK_METHOD1(release, void(const QObject *));
bool doEnabled();
void doAcquire(const QObject *object);
void doRelease(const QObject *object);
private:
QSet m_owners;
};
} // namespace qtmir
#endif // MOCK_SHARED_WAKELOCK_H
./tests/framework/mock_shared_wakelock.cpp 0000644 0000156 0000165 00000003206 12677054330 021107 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_shared_wakelock.h"
namespace qtmir
{
MockSharedWakelock::MockSharedWakelock(const QDBusConnection &)
{
using namespace ::testing;
ON_CALL(*this, enabled()).WillByDefault(Invoke(this, &MockSharedWakelock::doEnabled));
ON_CALL(*this, acquire(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doAcquire));
ON_CALL(*this, release(_)).WillByDefault(Invoke(this, &MockSharedWakelock::doRelease));
}
MockSharedWakelock::~MockSharedWakelock()
{
}
void MockSharedWakelock::doRelease(const QObject *object)
{
if (!m_owners.remove(object)) {
return;
}
if (m_owners.isEmpty()) {
Q_EMIT enabledChanged(false);
}
}
void MockSharedWakelock::doAcquire(const QObject *object)
{
if (m_owners.contains(object)) {
return;
}
m_owners.insert(object);
if (m_owners.size() == 1) {
Q_EMIT enabledChanged(true);
}
}
bool MockSharedWakelock::doEnabled()
{
return !m_owners.isEmpty();
}
} // namespace qtmir
./tests/framework/fake_session.h 0000644 0000156 0000165 00000005504 12677054330 017071 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include
#include
#ifndef QTMIR_FAKE_SESSION_H
#define QTMIR_FAKE_SESSION_H
namespace qtmir {
class FakeSession : public SessionInterface
{
Q_OBJECT
public:
FakeSession();
virtual ~FakeSession();
// For QML use
void release() override;
QString name() const override;
unity::shell::application::ApplicationInfoInterface* application() const override;
MirSurfaceInterface* lastSurface() const override;
const ObjectListModel* surfaces() const override;
SessionInterface* parentSession() const override;
SessionModel* childSessions() const override;
State state() const override;
bool fullscreen() const override;
bool live() const override;
std::shared_ptr session() const override;
// For MirSurfaceItem and MirSurfaceManager use
void registerSurface(MirSurfaceInterface*) override;
void removeSurface(MirSurfaceInterface*) override;
// For Application use
void setApplication(unity::shell::application::ApplicationInfoInterface* app) override;
void suspend() override;
void resume() override;
void stop() override;
void close() override;
// For SessionManager use
void addChildSession(SessionInterface*) override;
void insertChildSession(uint, SessionInterface*) override;
void removeChildSession(SessionInterface*) override;
void foreachChildSession(std::function) const override;
std::shared_ptr activePromptSession() const override;
void foreachPromptSession(std::function&)>) const override;
void setFullscreen(bool) override;
void setLive(const bool) override;
void appendPromptSession(const std::shared_ptr&) override;
void removePromptSession(const std::shared_ptr&) override;
// For tests
void setState(State state);
private:
unity::shell::application::ApplicationInfoInterface* m_application;
State m_state;
};
} // namespace qtmi
#endif // QTMIR_FAKE_SESSION_H
./tests/framework/stub_input_channel.cpp 0000644 0000156 0000165 00000002160 12677054330 020632 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "stub_input_channel.h"
namespace mir
{
namespace test
{
namespace doubles
{
StubInputChannel::StubInputChannel(int fd)
: input_fd(fd)
{
}
StubInputChannel::StubInputChannel()
: StubInputChannel(0)
{
}
StubInputChannel::~StubInputChannel()
{
}
int StubInputChannel::client_fd() const
{
return input_fd;
}
int StubInputChannel::server_fd() const
{
return input_fd;
}
} // namespace doubles
} // namespace test
} // namespace mir
./tests/framework/mock_desktop_file_reader.h 0000644 0000156 0000165 00000004200 12677054330 021413 0 ustar jenkins jenkins /*
* Copyright (C) 2013-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_DESKTOP_FILE_READER_H
#define MOCK_DESKTOP_FILE_READER_H
#include
#include
namespace qtmir
{
struct MockDesktopFileReader : public qtmir::DesktopFileReader
{
MockDesktopFileReader(const QString &appId, const QFileInfo& fileInfo);
virtual ~MockDesktopFileReader();
MOCK_CONST_METHOD0(file, QString());
MOCK_CONST_METHOD0(appId, QString ());
MOCK_CONST_METHOD0(name, QString());
MOCK_CONST_METHOD0(comment, QString());
MOCK_CONST_METHOD0(icon, QString());
MOCK_CONST_METHOD0(exec, QString());
MOCK_CONST_METHOD0(path, QString());
MOCK_CONST_METHOD0(stageHint, QString());
MOCK_CONST_METHOD0(isTouchApp, bool());
MOCK_CONST_METHOD0(loaded, bool());
QString doFile() const;
QString doAppId() const;
QString doName() const;
QString doComment() const;
QString doIcon() const;
QString doExec() const;
QString doPath() const;
QString doStageHint() const;
bool doIsTouchApp() const;
bool doLoaded() const;
};
struct MockDesktopFileReaderFactory : public qtmir::DesktopFileReader::Factory
{
MockDesktopFileReaderFactory();
virtual ~MockDesktopFileReaderFactory();
virtual qtmir::DesktopFileReader* doCreateInstance(const QString &appId, const QFileInfo &fi);
MOCK_METHOD2(createInstance, qtmir::DesktopFileReader*(const QString &appId, const QFileInfo &fi));
};
} // namespace qtmir
#endif // MOCK_DESKTOP_FILE_READER_H
./tests/framework/mock_session.h 0000644 0000156 0000165 00000005703 12677054330 017115 0 ustar jenkins jenkins /*
* Copyright (C) 2014-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_QTMIR_SESSION_H
#define MOCK_QTMIR_SESSION_H
#include
#include
namespace qtmir {
class MockSession : public SessionInterface {
public:
MockSession();
virtual ~MockSession();
MOCK_METHOD0(release, void());
MOCK_CONST_METHOD0(name, QString());
MOCK_CONST_METHOD0(application, unity::shell::application::ApplicationInfoInterface*());
MOCK_CONST_METHOD0(lastSurface, MirSurfaceInterface*());
MOCK_CONST_METHOD0(surfaces, const ObjectListModel*());
MOCK_CONST_METHOD0(parentSession, SessionInterface*());
MOCK_CONST_METHOD0(childSessions, SessionModel*());
MOCK_CONST_METHOD0(state, State());
MOCK_CONST_METHOD0(fullscreen, bool());
MOCK_CONST_METHOD0(live, bool());
MOCK_CONST_METHOD0(session, std::shared_ptr());
MOCK_METHOD1(registerSurface, void(MirSurfaceInterface* surface));
MOCK_METHOD1(removeSurface, void(MirSurfaceInterface* surface));
MOCK_METHOD1(setApplication, void(unity::shell::application::ApplicationInfoInterface* item));
MOCK_METHOD0(suspend, void());
MOCK_METHOD0(resume, void());
MOCK_METHOD0(close, void());
MOCK_METHOD0(stop, void());
MOCK_METHOD1(addChildSession, void(SessionInterface* session));
MOCK_METHOD2(insertChildSession, void(uint index, SessionInterface* session));
MOCK_METHOD1(removeChildSession, void(SessionInterface* session));
MOCK_CONST_METHOD1(foreachChildSession, void(std::function f));
MOCK_CONST_METHOD0(activePromptSession, std::shared_ptr());
MOCK_CONST_METHOD1(foreachPromptSession, void(std::function&)> f));
void setState(State state);
void doSuspend();
void doResume();
void doStop();
State doState() const;
protected:
MOCK_METHOD1(setFullscreen, void(bool fullscreen));
MOCK_METHOD1(setLive, void(const bool));
MOCK_METHOD1(appendPromptSession, void(const std::shared_ptr& session));
MOCK_METHOD1(removePromptSession, void(const std::shared_ptr& session));
private:
State m_state;
};
} // namespace qtmir
#endif // MOCK_QTMIR_SESSION_H
./tests/framework/mock_surface.h 0000644 0000156 0000165 00000010335 12677054330 017057 0 ustar jenkins jenkins /*
* Copyright (C) 2014-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_MIR_SCENE_SURFACE_H
#define MOCK_MIR_SCENE_SURFACE_H
#include
#include
#include
#include "mock_renderable.h"
namespace mir {
namespace scene {
struct MockSurface : public mir::scene::Surface
{
MockSurface();
virtual ~MockSurface();
MOCK_CONST_METHOD0(name, std::string());
MOCK_CONST_METHOD0(client_size, geometry::Size());
MOCK_CONST_METHOD0(input_bounds, geometry::Rectangle());
MOCK_CONST_METHOD0(top_left, geometry::Point());
MOCK_CONST_METHOD0(size, geometry::Size());
MOCK_CONST_METHOD1(generate_renderables,graphics::RenderableList(compositor::CompositorID id));
MOCK_CONST_METHOD0(parent, std::shared_ptr());
MOCK_CONST_METHOD0(alpha, float());
MOCK_CONST_METHOD0(type, MirSurfaceType());
MOCK_CONST_METHOD0(state, MirSurfaceState());
MOCK_METHOD0(hide, void());
MOCK_METHOD0(show, void());
MOCK_CONST_METHOD0(visible, bool());
MOCK_METHOD1(move_to, void(geometry::Point const& top_left));
MOCK_METHOD1(take_input_focus, void(std::shared_ptr const& targeter));
MOCK_METHOD1(set_input_region, void(std::vector const& region));
MOCK_METHOD1(allow_framedropping, void(bool));
MOCK_METHOD1(resize, void(geometry::Size const& size));
MOCK_METHOD1(set_transformation, void(glm::mat4 const& t));
MOCK_METHOD1(set_alpha, void(float alpha));
MOCK_METHOD1(set_orientation, void(MirOrientation orientation));
MOCK_METHOD0(force_requests_to_complete, void());
MOCK_METHOD1(set_cursor_image, void(std::shared_ptr const& image));
MOCK_CONST_METHOD0(cursor_image, std::shared_ptr());
MOCK_METHOD1(add_observer, void(std::shared_ptr const& observer));
MOCK_METHOD1(remove_observer, void(std::weak_ptr const& observer));
MOCK_CONST_METHOD0(input_channel, std::shared_ptr());
MOCK_METHOD1(set_reception_mode, void(input::InputReceptionMode mode));
MOCK_METHOD0(request_client_surface_close, void());
MOCK_CONST_METHOD1(buffers_ready_for_compositor, int(void const*));
void set_keymap(MirInputDeviceId, std::string const&, std::string const&,
std::string const&, std::string const&) override;
void rename(std::string const&) override;
MOCK_METHOD1(set_streams, void(std::list const&));
// from mir::input::surface
MOCK_CONST_METHOD1(input_area_contains, bool(geometry::Point const& point));
MOCK_CONST_METHOD0(reception_mode, input::InputReceptionMode());
MOCK_METHOD1(consume, void(MirEvent const* event));
//void consume(MirEvent const* event) override;
// from mir::frontend::surface
MOCK_CONST_METHOD0(pixel_format, MirPixelFormat());
MOCK_METHOD2(swap_buffers, void(graphics::Buffer* old_buffer, std::function complete));
MOCK_CONST_METHOD0(supports_input, bool());
MOCK_CONST_METHOD0(client_input_fd, int());
MOCK_METHOD2(configure, int(MirSurfaceAttrib attrib, int value));
MOCK_CONST_METHOD1(query, int(MirSurfaceAttrib attrib));
MOCK_CONST_METHOD0(primary_buffer_stream, std::shared_ptr());
// from mir::scene::SurfaceBufferAccess
MOCK_METHOD1(with_most_recent_buffer_do, void(std::function const& exec));
MOCK_METHOD2(set_cursor_stream, void(std::shared_ptr const&, geometry::Displacement const&));
};
} // namespace scene
} // namespace mir
#endif // MOCK_MIR_SCENE_SURFACE_H
./tests/framework/stub_scene_surface.h 0000644 0000156 0000165 00000005531 12677054330 020262 0 ustar jenkins jenkins /*
* Copyright (C) 2014-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MIR_TEST_DOUBLES_STUB_SCENE_SURFACE_H_
#define MIR_TEST_DOUBLES_STUB_SCENE_SURFACE_H_
#include "mir/scene/surface.h"
#include "stub_input_channel.h"
#include
#include
namespace mir
{
namespace test
{
namespace doubles
{
class StubSceneSurface :
public mir::scene::Surface
{
public:
std::shared_ptr channel;
int fd;
mir::input::InputReceptionMode input_mode{mir::input::InputReceptionMode::normal};
StubSceneSurface(int fd);
virtual ~StubSceneSurface();
std::shared_ptr input_channel() const override;
mir::input::InputReceptionMode reception_mode() const override;
std::string name() const override;
geometry::Point top_left() const override;
geometry::Size client_size() const override;
geometry::Size size() const override;
geometry::Rectangle input_bounds() const override;
bool input_area_contains(mir::geometry::Point const&) const override;
graphics::RenderableList generate_renderables(compositor::CompositorID) const override;
float alpha() const override;
MirSurfaceType type() const override;
MirSurfaceState state() const override;
void hide() override;
void show() override;
void move_to(geometry::Point const&) override;
void set_input_region(std::vector const&) override;
void resize(geometry::Size const&) override;
void set_transformation(glm::mat4 const&) override;
void set_alpha(float) override;
void set_orientation(MirOrientation) override;
void add_observer(std::shared_ptr const&) override;
void remove_observer(std::weak_ptr const&) override;
void set_reception_mode(input::InputReceptionMode mode) override;
void consume(MirEvent const*) override;
void set_cursor_image(std::shared_ptr const& /* image */) override;
std::shared_ptr cursor_image() const override;
bool supports_input() const override;
int client_input_fd() const override;
int configure(MirSurfaceAttrib, int) override;
int query(MirSurfaceAttrib) const override;
};
}
}
}
#endif
./tests/framework/qtmir_test.cpp 0000644 0000156 0000165 00000012644 12677054330 017151 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "qtmir_test.h"
namespace qtmir {
void PrintTo(const Application::InternalState& state, ::std::ostream* os)
{
switch (state) {
case Application::InternalState::Starting:
*os << "Starting";
break;
case Application::InternalState::Running:
*os << "Running";
break;
case Application::InternalState::RunningInBackground:
*os << "RunningInBackground";
break;
case Application::InternalState::SuspendingWaitSession:
*os << "SuspendingWaitSession";
break;
case Application::InternalState::SuspendingWaitProcess:
*os << "SuspendingWaitProcess";
break;
case Application::InternalState::Suspended:
*os << "Suspended";
break;
case Application::InternalState::StoppedResumable:
*os << "StoppedResumable";
break;
case Application::InternalState::Closing:
*os << "Closing";
break;
case Application::InternalState::Stopped:
*os << "Stopped";
break;
default:
*os << "???";
break;
}
}
void PrintTo(const Session::State& state, ::std::ostream* os)
{
switch (state) {
case SessionInterface::Starting:
*os << "Starting";
break;
case SessionInterface::Running:
*os << "Running";
break;
case SessionInterface::Suspending:
*os << "Suspending";
break;
case SessionInterface::Suspended:
*os << "Suspended";
break;
case SessionInterface::Stopped:
*os << "Stopped";
break;
default:
*os << "???";
break;
}
}
// Initialization of mir::Server needed for by tests
class TestMirServerInit : public virtual mir::Server
{
public:
TestMirServerInit(std::shared_ptr const& promptSessionManager)
: mock_prompt_session_manager(promptSessionManager)
{
override_the_prompt_session_manager(
[this]{ return the_mock_prompt_session_manager(); });
}
std::shared_ptr the_mock_prompt_session_manager()
{
return mock_prompt_session_manager;
}
private:
std::shared_ptr const mock_prompt_session_manager;
};
namespace { int argc = 0; char* argv[] = { nullptr }; }
class FakeMirServer: private TestMirServerInit, public MirServer
{
public:
FakeMirServer(std::shared_ptr const& promptSessionManager)
: TestMirServerInit(promptSessionManager), MirServer(argc, argv, QSharedPointer())
{
}
using TestMirServerInit::the_mock_prompt_session_manager;
};
} // namespace qtmir
namespace testing
{
QtMirTest::QtMirTest()
: promptSessionManager(std::make_shared())
, mirServer(QSharedPointer(new FakeMirServer(promptSessionManager)))
, applicationManager(mirServer,
taskControllerSharedPointer,
QSharedPointer(&sharedWakelock, [](MockSharedWakelock *){}),
QSharedPointer(&desktopFileReaderFactory,[](DesktopFileReader::Factory*){}),
QSharedPointer(&procInfo,[](ProcInfo *){}),
QSharedPointer(&settings,[](MockSettings *){}))
, sessionManager(mirServer, &applicationManager)
, surfaceManager(mirServer, mirShell, &sessionManager)
{
}
QtMirTest::~QtMirTest()
{
}
Application *QtMirTest::startApplication(pid_t procId, const QString &appId)
{
using namespace testing;
ON_CALL(*taskController,appIdHasProcessId(appId, procId)).WillByDefault(Return(true));
// Set up Mocks & signal watcher
auto mockDesktopFileReader = new NiceMock(appId, QFileInfo());
ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId));
EXPECT_CALL(desktopFileReaderFactory, createInstance(appId, _))
.Times(1)
.WillOnce(Return(mockDesktopFileReader));
EXPECT_CALL(*taskController, start(appId, _))
.Times(1)
.WillOnce(Return(true));
auto application = applicationManager.startApplication(appId);
applicationManager.onProcessStarting(appId);
bool authed = false;
applicationManager.authorizeSession(procId, authed);
EXPECT_EQ(authed, true);
auto appSession = std::make_shared(appId.toStdString(), procId);
applicationManager.onSessionStarting(appSession);
sessionManager.onSessionStarting(appSession);
Mock::VerifyAndClearExpectations(taskController);
Mock::VerifyAndClearExpectations(&desktopFileReaderFactory);
return application;
}
} // namespace testing
./tests/framework/mock_gl_display_buffer.h 0000644 0000156 0000165 00000003064 12677054330 021110 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_GL_DISPLAY_BUFFER_H
#define MOCK_GL_DISPLAY_BUFFER_H
#include
#include
#include
class MockGLDisplayBuffer : public mir::graphics::DisplayBuffer,
public mir::renderer::gl::RenderTarget,
public mir::graphics::NativeDisplayBuffer
{
public:
MockGLDisplayBuffer();
virtual ~MockGLDisplayBuffer();
MOCK_CONST_METHOD0(view_area, mir::geometry::Rectangle());
MOCK_METHOD1(post_renderables_if_optimizable, bool(mir::graphics::RenderableList const&));
MOCK_CONST_METHOD0(orientation, MirOrientation());
MOCK_METHOD0(native_display_buffer, mir::graphics::NativeDisplayBuffer*());
MOCK_METHOD0(make_current, void());
MOCK_METHOD0(release_current, void());
MOCK_METHOD0(swap_buffers, void());
};
#endif // MOCK_GL_DISPLAY_BUFFER_H
./tests/framework/mock_main_loop.cpp 0000644 0000156 0000165 00000001477 12677054330 017746 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_main_loop.h"
MockMainLoop::MockMainLoop()
{
}
MockMainLoop::~MockMainLoop()
{
}
void MockMainLoop::run() {}
void MockMainLoop::stop() {} ./tests/framework/mock_display.cpp 0000644 0000156 0000165 00000001706 12677054330 017431 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_display.h"
#include
#include
MockDisplaySyncGroup::MockDisplaySyncGroup()
{
}
MockDisplaySyncGroup::~MockDisplaySyncGroup()
{
}
MockDisplay::MockDisplay()
{
}
MockDisplay::~MockDisplay()
{
}
./tests/framework/mock_settings.cpp 0000644 0000156 0000165 00000002021 12677054330 017613 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_settings.h"
namespace qtmir
{
MockSettings::MockSettings()
{
using namespace ::testing;
QVariantList lifecycleExemptAppIds;
lifecycleExemptAppIds << "com.ubuntu.music";
ON_CALL(*this, get(_))
.WillByDefault(
Return(lifecycleExemptAppIds));
}
MockSettings::~MockSettings()
{
}
} // namespace qtmir
./tests/framework/mock_task_controller.h 0000644 0000156 0000165 00000003615 12677054330 020637 0 ustar jenkins jenkins /*
* Copyright (C) 2013-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_TASK_CONTROLLER_H
#define MOCK_TASK_CONTROLLER_H
#include
#include
#include
#include
namespace qtmir
{
struct MockTaskController : public qtmir::TaskController
{
MockTaskController();
virtual ~MockTaskController();
MOCK_METHOD1(primaryPidForAppId, pid_t(const QString& appId));
MOCK_METHOD2(appIdHasProcessId, bool(const QString&, pid_t));
MOCK_CONST_METHOD1(findDesktopFileForAppId, QFileInfo(const QString &appId));
MOCK_METHOD1(stop, bool(const QString&));
MOCK_METHOD2(start, bool(const QString&, const QStringList&));
MOCK_METHOD1(suspend, bool(const QString&));
MOCK_METHOD1(resume, bool(const QString&));
pid_t doPrimaryPidForAppId(const QString& appId);
bool doAppIdHasProcessId(const QString& appId, pid_t pid);
QFileInfo doFindDesktopFileForAppId(const QString& appId) const;
bool doStop(const QString& appId);
bool doStart(const QString& appId, const QStringList& args);
bool doSuspend(const QString& appId);
bool doResume(const QString& appId);
private:
QMap children;
};
} // namespace qtmir
#endif // MOCK_TASK_CONTROLLER_H
./tests/framework/mock_renderable.cpp 0000644 0000156 0000165 00000001541 12677054330 020064 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_renderable.h"
namespace mir
{
namespace graphics
{
MockRenderable::MockRenderable()
{
}
MockRenderable::~MockRenderable()
{
}
} // namespace graphics
} // namespace mir
./tests/framework/CMakeLists.txt 0000644 0000156 0000165 00000002016 12677054330 017002 0 ustar jenkins jenkins include_directories(
${APPLICATION_API_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}/src/platforms/mirserver
${CMAKE_SOURCE_DIR}/src/modules
${MIRSERVER_INCLUDE_DIRS}
${MIRRENDERERGLDEV_INCLUDE_DIRS}
${Qt5Quick_INCLUDE_DIRS}
${Qt5DBus_INCLUDE_DIRS}
)
set(QTMIR_TEST_PRIVATE_SRC
fake_desktopfilereader.cpp
fake_mirsurface.cpp
fake_session.cpp
mock_task_controller.cpp
mock_desktop_file_reader.cpp
mock_display.cpp
mock_display_configuration.cpp
mock_gl_display_buffer.cpp
mock_main_loop.cpp
mock_mir_session.cpp
mock_proc_info.cpp
mock_prompt_session.cpp
mock_prompt_session_manager.cpp
mock_renderable.cpp
mock_session.cpp
mock_settings.cpp
mock_shared_wakelock.cpp
mock_surface.cpp
stub_input_channel.cpp
stub_scene_surface.cpp
qtmir_test.cpp
)
add_library(qtmir-test-framework-static STATIC
${QTMIR_TEST_PRIVATE_SRC}
)
target_link_libraries(
qtmir-test-framework-static
${GTEST_BOTH_LIBRARIES}
${GMOCK_LIBRARIES}
)
./tests/framework/fake_mirsurface.h 0000644 0000156 0000165 00000012025 12677054330 017542 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef FAKE_MIRSURFACEINTERFACE_H
#define FAKE_MIRSURFACEINTERFACE_H
#include
#include
#include
#include
namespace qtmir {
class FakeMirSurface : public MirSurfaceInterface
{
Q_OBJECT
public:
class TouchEvent {
public:
TouchEvent(Qt::KeyboardModifiers mods,
const QList &points,
Qt::TouchPointStates states,
ulong timestamp);
virtual ~TouchEvent();
Qt::KeyboardModifiers keyboardModifiers;
QList touchPoints;
Qt::TouchPointStates states;
ulong timestamp;
};
FakeMirSurface(QObject *parent = nullptr);
virtual ~FakeMirSurface();
////
// unity.shell.application.MirSurfaceInterface
Mir::Type type() const override;
QString name() const override;
QSize size() const override;
void resize(int width, int height) override;
void resize(const QSize &size) override;
Mir::State state() const override;
void setState(Mir::State qmlState) override;
bool live() const override;
bool visible() const override;
Mir::OrientationAngle orientationAngle() const override;
void setOrientationAngle(Mir::OrientationAngle angle) override;
int minimumWidth() const override { return 0; }
int minimumHeight() const override { return 0; }
int maximumWidth() const override { return 0; }
int maximumHeight() const override { return 0; }
int widthIncrement() const override { return 0; }
int heightIncrement() const override { return 0; }
////
// qtmir.MirSurfaceInterface
bool isFirstFrameDrawn() const override;
void stopFrameDropper() override;
void startFrameDropper() override;
void setLive(bool value) override;
void setViewVisibility(qintptr viewId, bool visible) override;
bool isBeingDisplayed() const override;
void registerView(qintptr viewId) override;
void unregisterView(qintptr viewId) override;
// methods called from the rendering (scene graph) thread:
QSharedPointer texture() override;
QSGTexture *weakTexture() const override;
bool updateTexture() override;
unsigned int currentFrameNumber() const override;
bool numBuffersReadyForCompositor() override;
// end of methods called from the rendering (scene graph) thread
void setFocus(bool focus) override;
void mousePressEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
void hoverEnterEvent(QHoverEvent *) override;
void hoverLeaveEvent(QHoverEvent *) override;
void hoverMoveEvent(QHoverEvent *) override;
void wheelEvent(QWheelEvent *) override;
void keyPressEvent(QKeyEvent *) override;
void keyReleaseEvent(QKeyEvent *) override;
void touchEvent(Qt::KeyboardModifiers mods,
const QList &points,
Qt::TouchPointStates states,
ulong timestamp) override;
QString appId() const override;
QCursor cursor() const override { return QCursor(); }
Mir::ShellChrome shellChrome() const override { return Mir::NormalChrome; }
void setShellChrome(Mir::ShellChrome) override {}
void close() override {
Q_EMIT closeRequested();
}
QString keymapLayout() const override { return QString(); }
QString keymapVariant() const override { return QString(); }
void setKeymap(const QString &layout, const QString &variant) override;
Q_SIGNALS:
void closeRequested();
public Q_SLOTS:
void onCompositorSwappedBuffers() override;
void setMinimumWidth(int) {}
void setMinimumHeight(int) {}
void setMaximumWidth(int) {}
void setMaximumHeight(int) {}
void setWidthIncrement(int) {}
void setHeightIncrement(int) {}
////
// Test API from now on
public:
void drawFirstFrame();
bool isFrameDropperRunning() const;
QList &touchesReceived();
private:
void updateVisibility();
bool m_isFirstFrameDrawn;
bool m_isFrameDropperRunning;
bool m_live;
Mir::State m_state;
Mir::OrientationAngle m_orientationAngle;
bool m_visible;
QSize m_size;
QHash m_views;
bool m_focused;
QList m_touchesReceived;
};
} // namespace qtmir
#endif // FAKE_MIRSURFACEINTERFACE_H
./tests/framework/qtmir_test.h 0000644 0000156 0000165 00000005435 12677054330 016616 0 ustar jenkins jenkins /*
* Copyright (C) 2014-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef QT_MIR_TEST_FRAMEWORK_H
#define QT_MIR_TEST_FRAMEWORK_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "mock_desktop_file_reader.h"
#include "mock_proc_info.h"
#include "mock_mir_session.h"
#include "mock_prompt_session_manager.h"
#include "mock_prompt_session.h"
#include "mock_shared_wakelock.h"
#include "mock_settings.h"
#include "mock_task_controller.h"
namespace ms = mir::scene;
using namespace qtmir;
namespace qtmir {
typedef testing::NiceMock StubPromptSessionManager;
// For better output in ASSERT_* and EXPECT_* error messages
void PrintTo(const Application::InternalState& state, ::std::ostream* os);
void PrintTo(const SessionInterface::State& state, ::std::ostream* os);
} // namespace qtmir
namespace testing {
class QtMirTest : public ::testing::Test
{
public:
QtMirTest();
virtual ~QtMirTest();
Application* startApplication(pid_t procId, QString const& appId);
QSharedPointer taskControllerSharedPointer{new testing::NiceMock};
testing::NiceMock *taskController{static_cast*>(taskControllerSharedPointer.data())};
testing::NiceMock procInfo;
testing::NiceMock desktopFileReaderFactory;
testing::NiceMock sharedWakelock;
testing::NiceMock settings;
std::shared_ptr promptSessionManager;
QSharedPointer mirServer;
MirShell *mirShell{nullptr};
ApplicationManager applicationManager;
SessionManager sessionManager;
MirSurfaceManager surfaceManager;
};
} // namespace testing
#endif // QT_MIR_TEST_FRAMEWORK_H
./tests/framework/mock_prompt_session.h 0000644 0000156 0000165 00000002433 12677054330 020513 0 ustar jenkins jenkins /*
* Copyright (C) 2014-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_MIR_PROMPT_SESSION_H
#define MOCK_MIR_PROMPT_SESSION_H
#include
#include
namespace mir {
namespace scene {
struct MockPromptSession : public PromptSession
{
public:
MockPromptSession();
virtual ~MockPromptSession();
MOCK_METHOD1(start, void(std::shared_ptr const&));
MOCK_METHOD1(stop, void(std::shared_ptr const&));
MOCK_METHOD1(suspend, void(std::shared_ptr const&));
MOCK_METHOD1(resume, void(std::shared_ptr const&));
};
} // namespace scene
} // namespace mir
#endif // MOCK_MIR_PROMPT_SESSION_H
./tests/framework/mock_desktop_file_reader.cpp 0000644 0000156 0000165 00000006620 12677054330 021756 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_desktop_file_reader.h"
namespace qtmir
{
MockDesktopFileReader::MockDesktopFileReader(const QString &appId, const QFileInfo &fileInfo)
: DesktopFileReader(appId, fileInfo)
{
using namespace ::testing;
ON_CALL(*this, file()).WillByDefault(Invoke(this, &MockDesktopFileReader::doFile));
ON_CALL(*this, appId()).WillByDefault(Invoke(this, &MockDesktopFileReader::doAppId));
ON_CALL(*this, name()).WillByDefault(Invoke(this, &MockDesktopFileReader::doName));
ON_CALL(*this, comment()).WillByDefault(Invoke(this, &MockDesktopFileReader::doComment));
ON_CALL(*this, icon()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIcon));
ON_CALL(*this, exec()).WillByDefault(Invoke(this, &MockDesktopFileReader::doExec));
ON_CALL(*this, path()).WillByDefault(Invoke(this, &MockDesktopFileReader::doPath));
ON_CALL(*this, stageHint()).WillByDefault(Invoke(this, &MockDesktopFileReader::doStageHint));
ON_CALL(*this, isTouchApp()).WillByDefault(Invoke(this, &MockDesktopFileReader::doIsTouchApp));
ON_CALL(*this, loaded()).WillByDefault(Invoke(this, &MockDesktopFileReader::doLoaded));
}
MockDesktopFileReader::~MockDesktopFileReader()
{
}
QString MockDesktopFileReader::doFile() const
{
return DesktopFileReader::file();
}
QString MockDesktopFileReader::doAppId() const
{
return DesktopFileReader::appId();
}
QString MockDesktopFileReader::doName() const
{
return DesktopFileReader::name();
}
QString MockDesktopFileReader::doComment() const
{
return DesktopFileReader::comment();
}
QString MockDesktopFileReader::doIcon() const
{
return DesktopFileReader::icon();
}
QString MockDesktopFileReader::doExec() const
{
return DesktopFileReader::exec();
}
QString MockDesktopFileReader::doPath() const
{
return DesktopFileReader::path();
}
QString MockDesktopFileReader::doStageHint() const
{
return DesktopFileReader::stageHint();
}
bool MockDesktopFileReader::doIsTouchApp() const
{
return DesktopFileReader::isTouchApp();
}
bool MockDesktopFileReader::doLoaded() const
{
return DesktopFileReader::loaded();
}
MockDesktopFileReaderFactory::MockDesktopFileReaderFactory()
{
using namespace ::testing;
ON_CALL(*this, createInstance(_, _))
.WillByDefault(
Invoke(
this,
&MockDesktopFileReaderFactory::doCreateInstance));
}
MockDesktopFileReaderFactory::~MockDesktopFileReaderFactory()
{
}
qtmir::DesktopFileReader *MockDesktopFileReaderFactory::doCreateInstance(const QString &appId, const QFileInfo &fi)
{
using namespace ::testing;
auto instance = new NiceMock(appId, fi);
ON_CALL(*instance, loaded()).WillByDefault(Return(true));
return instance;
}
} // namespace qtmir
./tests/framework/gmock_fixes.h 0000644 0000156 0000165 00000010270 12677054330 016712 0 ustar jenkins jenkins //
// Copyright © 2012 Canonical Ltd. Copyright 2007, Google Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Author: wan@google.com (Zhanyong Wan)
// Authored by: Alan Griffiths
#ifndef MIR_TEST_GMOCK_FIXES_H_
#define MIR_TEST_GMOCK_FIXES_H_
#include
#include
namespace testing
{
namespace internal
{
template
class ActionResultHolder>
: public UntypedActionResultHolderBase {
public:
explicit ActionResultHolder(std::unique_ptr&& a_value) :
value_(std::move(a_value)) {}
// The compiler-generated copy constructor and assignment operator
// are exactly what we need, so we don't need to define them.
// Returns the held value and deletes this object.
std::unique_ptr GetValueAndDelete() const {
std::unique_ptr retval(std::move(value_));
delete this;
return retval;
}
// Prints the held value as an action's result to os.
virtual void PrintAsActionResult(::std::ostream* os) const {
*os << "\n Returns: ";
// T may be a reference type, so we don't use UniversalPrint().
UniversalPrinter>::Print(value_, os);
}
// Performs the given mock function's default action and returns the
// result in a new-ed ActionResultHolder.
template
static ActionResultHolder* PerformDefaultAction(
const FunctionMockerBase* func_mocker,
const typename Function::ArgumentTuple& args,
const string& call_description) {
return new ActionResultHolder(
func_mocker->PerformDefaultAction(args, call_description));
}
// Performs the given action and returns the result in a new-ed
// ActionResultHolder.
template
static ActionResultHolder*
PerformAction(const Action& action,
const typename Function::ArgumentTuple& args) {
return new ActionResultHolder(action.Perform(args));
}
private:
std::unique_ptr mutable value_;
// T could be a reference type, so = isn't supported.
GTEST_DISALLOW_ASSIGN_(ActionResultHolder);
};
}
template
class DefaultValue> {
public:
// Unsets the default value for type T.
static void Clear() {}
// Returns true iff the user has set the default value for type T.
static bool IsSet() { return false; }
// Returns true if T has a default return value set by the user or there
// exists a built-in default value.
static bool Exists() {
return true;
}
// Returns the default value for type T if the user has set one;
// otherwise returns the built-in default value if there is one;
// otherwise aborts the process.
static std::unique_ptr Get() {
return std::unique_ptr();
}
};
}
#endif /* MIR_TEST_GMOCK_FIXES_H_ */
./tests/framework/fake_desktopfilereader.h 0000644 0000156 0000165 00000003447 12677054330 021106 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef FAKE_DESKTOPFILEREADER_H
#define FAKE_DESKTOPFILEREADER_H
#include
namespace qtmir {
class FakeDesktopFileReader : public qtmir::DesktopFileReader
{
public:
FakeDesktopFileReader(const QString &appId);
FakeDesktopFileReader();
virtual ~FakeDesktopFileReader();
QString file() const override;
QString appId() const override;
QString name() const override;
QString comment() const override;
QString icon() const override;
QString exec() const override;
QString path() const override;
QString stageHint() const override;
QString splashTitle() const override;
QString splashImage() const override;
QString splashShowHeader() const override;
QString splashColor() const override;
QString splashColorHeader() const override;
QString splashColorFooter() const override;
Qt::ScreenOrientations supportedOrientations() const override;
bool rotatesWindowContents() const override;
bool isTouchApp() const override;
bool loaded() const override;
QString m_appId;
};
} // namespace qtmir
#endif // FAKE_DESKTOPFILEREADER_H
./tests/framework/mock_prompt_session_manager.h 0000644 0000156 0000165 00000004434 12677054330 022210 0 ustar jenkins jenkins /*
* Copyright (C) 2014-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_MIR_SCENE_PROMPT_SESSION_MANAGER_H_
#define MOCK_MIR_SCENE_PROMPT_SESSION_MANAGER_H_
#include "mir/scene/prompt_session_manager.h"
#include "mir/scene/prompt_session_creation_parameters.h"
#include
namespace mir {
namespace scene {
class MockPromptSessionManager: public PromptSessionManager
{
public:
MockPromptSessionManager();
virtual ~MockPromptSessionManager();
MOCK_CONST_METHOD2(start_prompt_session_for, std::shared_ptr(std::shared_ptr const&,
mir::scene::PromptSessionCreationParameters const&));
MOCK_CONST_METHOD1(stop_prompt_session, void(std::shared_ptr const&));
MOCK_CONST_METHOD1(suspend_prompt_session, void(std::shared_ptr const&));
MOCK_CONST_METHOD1(resume_prompt_session, void(std::shared_ptr const&));
MOCK_CONST_METHOD2(add_prompt_provider, void(std::shared_ptr const&,
std::shared_ptr const&));
MOCK_CONST_METHOD1(add_expected_session, void(std::shared_ptr const&));
MOCK_CONST_METHOD1(remove_session, void(std::shared_ptr const&));
MOCK_CONST_METHOD1(application_for, std::shared_ptr(std::shared_ptr const&));
MOCK_CONST_METHOD1(helper_for, std::shared_ptr(std::shared_ptr const&));
MOCK_CONST_METHOD2(for_each_provider_in, void(std::shared_ptr const&,
std::function const&)> const&));
};
} // namespace scene
} // namespace mir
#endif // MOCK_MIR_SCENE_PROMPT_SESSION_MANAGER_H_
./tests/framework/mock_session.cpp 0000644 0000156 0000165 00000003432 12677054330 017445 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_session.h"
namespace qtmir
{
MockSession::MockSession()
: SessionInterface(0)
{
m_state = Starting;
ON_CALL(*this, name()).WillByDefault(::testing::Return(QString()));
ON_CALL(*this, suspend()).WillByDefault(::testing::Invoke(this, &MockSession::doSuspend));
ON_CALL(*this, resume()).WillByDefault(::testing::Invoke(this, &MockSession::doResume));
ON_CALL(*this, stop()).WillByDefault(::testing::Invoke(this, &MockSession::doStop));
ON_CALL(*this, state()).WillByDefault(::testing::Invoke(this, &MockSession::doState));
}
MockSession::~MockSession()
{
}
SessionInterface::State MockSession::doState() const
{
return m_state;
}
void MockSession::doStop()
{
setState(Stopped);
}
void MockSession::doResume()
{
if (m_state == Suspending || m_state == Suspended) {
setState(Running);
}
}
void MockSession::doSuspend()
{
if (m_state == Running) {
setState(Suspending);
}
}
void MockSession::setState(SessionInterface::State state)
{
if (m_state != state) {
m_state = state;
Q_EMIT stateChanged(m_state);
}
}
} // namespace qtmir
./tests/framework/mock_display_configuration.h 0000644 0000156 0000165 00000002757 12677054330 022034 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#ifndef MOCK_DISPLAY_CONFIGURATION_H
#define MOCK_DISPLAY_CONFIGURATION_H
#include
#include
#include "gmock_fixes.h"
class MockDisplayConfiguration : public mir::graphics::DisplayConfiguration
{
public:
MockDisplayConfiguration();
virtual ~MockDisplayConfiguration();
MOCK_CONST_METHOD1(for_each_card, void(std::function));
MOCK_CONST_METHOD1(for_each_output, void(std::function));
MOCK_METHOD1(for_each_output, void(std::function));
MOCK_CONST_METHOD0(clone, std::unique_ptr());
MOCK_CONST_METHOD0(valid, bool());
};
#endif // MOCK_DISPLAY_CONFIGURATION_H
./tests/framework/mock_mir_session.cpp 0000644 0000156 0000165 00000003004 12677054330 020307 0 ustar jenkins jenkins /*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#include "mock_mir_session.h"
namespace mir
{
namespace scene
{
MockSession::MockSession()
{
}
MockSession::MockSession(const std::string &sessionName, pid_t processId)
: m_sessionName(sessionName), m_sessionId(processId)
{
}
MockSession::~MockSession()
{
}
std::string MockSession::name() const
{
return m_sessionName;
}
pid_t MockSession::process_id() const
{
return m_sessionId;
}
void MockSession::resume_prompt_session() {}
void MockSession::suspend_prompt_session() {}
void MockSession::stop_prompt_session() {}
void MockSession::start_prompt_session() {}
std::shared_ptr MockSession::surface_after(const std::shared_ptr &) const
{
return {};
}
void MockSession::configure_streams(scene::Surface &, const std::vector &) {}
} // namespace scene
} // namespace mir
./tests/modules/ 0000755 0000156 0000165 00000000000 12677054330 013716 5 ustar jenkins jenkins ./tests/modules/ApplicationManager/ 0000755 0000156 0000165 00000000000 12677054330 017454 5 ustar jenkins jenkins ./tests/modules/ApplicationManager/application_manager_test.cpp 0000644 0000156 0000165 00000243322 12677054330 025222 0 ustar jenkins jenkins /*
* Copyright (C) 2013-2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*/
#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace qtmir;
using mir::scene::MockSession;
namespace ms = mir::scene;
class ApplicationManagerTests : public ::testing::QtMirTest
{
public:
ApplicationManagerTests()
{}
inline void onSessionStarting(const std::shared_ptr &session) {
applicationManager.onSessionStarting(session);
sessionManager.onSessionStarting(session);
}
inline void onSessionStopping(const std::shared_ptr &session) {
applicationManager.onSessionStopping(session);
sessionManager.onSessionStopping(session);
}
inline void onSessionCreatedSurface(const mir::scene::Session *mirSession,
MirSurfaceInterface *qmlSurface) {
SessionInterface* qmlSession = sessionManager.findSession(mirSession);
if (qmlSession) {
qmlSession->registerSurface(qmlSurface);
}
// I assume that applicationManager ignores the mirSurface parameter, so sending
// a null shared pointer must suffice
std::shared_ptr mirSurface(nullptr);
applicationManager.onSessionCreatedSurface(mirSession, mirSurface);
}
inline void suspend(Application *application) {
application->setRequestedState(Application::RequestedSuspended);
ASSERT_EQ(Application::InternalState::SuspendingWaitSession, application->internalState());
static_cast(application->session())->doSuspend();
ASSERT_EQ(Application::InternalState::SuspendingWaitProcess, application->internalState());
applicationManager.onProcessSuspended(application->appId());
ASSERT_EQ(Application::InternalState::Suspended, application->internalState());
}
static inline qtmir::DesktopFileReader* createMockDesktopFileReader(const QString &appId, const QFileInfo &fi) {
using namespace ::testing;
auto mockDesktopFileReader = new NiceMock(appId, fi);
ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
return mockDesktopFileReader;
}
protected:
virtual void SetUp() override {
if (m_tempDir.isValid()) qputenv("XDG_CACHE_HOME", m_tempDir.path().toUtf8());
}
private:
const QTemporaryDir m_tempDir;
};
TEST_F(ApplicationManagerTests,bug_case_1240400_second_dialer_app_fails_to_authorize_and_gets_mixed_up_with_first_one)
{
using namespace ::testing;
const pid_t firstProcId = 5921;
const pid_t secondProcId = 5922;
const char dialer_app_id[] = "dialer-app";
QByteArray cmdLine( "/usr/bin/dialer-app --desktop_file_hint=dialer-app");
QByteArray secondcmdLine( "/usr/bin/dialer-app");
FakeMirSurface *surface = new FakeMirSurface;
EXPECT_CALL(procInfo,command_line(firstProcId))
.Times(1)
.WillOnce(Return(cmdLine));
EXPECT_CALL(procInfo,command_line(secondProcId))
.Times(1)
.WillOnce(Return(secondcmdLine));
bool authed = true;
std::shared_ptr mirSession = std::make_shared(dialer_app_id, firstProcId);
applicationManager.authorizeSession(firstProcId, authed);
ASSERT_EQ(true, authed);
onSessionStarting(mirSession);
onSessionCreatedSurface(mirSession.get(), surface);
surface->drawFirstFrame();
Application * application = applicationManager.findApplication(dialer_app_id);
ASSERT_NE(nullptr,application);
ASSERT_EQ(Application::InternalState::Running, application->internalState());
// now a second session without desktop file is launched:
applicationManager.authorizeSession(secondProcId, authed);
applicationManager.onProcessStarting(dialer_app_id);
EXPECT_FALSE(authed);
EXPECT_EQ(application, applicationManager.findApplication(dialer_app_id));
}
TEST_F(ApplicationManagerTests,application_dies_while_starting)
{
using namespace ::testing;
const pid_t procId = 5921;
const char app_id[] = "my-app";
QByteArray cmdLine( "/usr/bin/my-app --desktop_file_hint=my-app");
EXPECT_CALL(procInfo,command_line(procId))
.Times(1)
.WillOnce(Return(cmdLine));
bool authed = true;
std::shared_ptr mirSession = std::make_shared(app_id, procId);
applicationManager.authorizeSession(procId, authed);
onSessionStarting(mirSession);
Application * beforeFailure = applicationManager.findApplication(app_id);
applicationManager.onProcessStarting(app_id);
onSessionStopping(mirSession);
applicationManager.onProcessFailed(app_id, TaskController::Error::APPLICATION_FAILED_TO_START);
Application * afterFailure = applicationManager.findApplication(app_id);
EXPECT_EQ(true, authed);
EXPECT_NE(nullptr, beforeFailure);
EXPECT_EQ(nullptr, afterFailure);
}
TEST_F(ApplicationManagerTests,startApplicationSupportsShortAppId)
{
using namespace ::testing;
const QString shortAppId("com.canonical.test_test");
EXPECT_CALL(*taskController, start(_, _)).Times(1);
EXPECT_CALL(*taskController, findDesktopFileForAppId(shortAppId)).Times(1);
EXPECT_CALL(desktopFileReaderFactory, createInstance(_, _)).Times(1);
auto application = applicationManager.startApplication(
shortAppId,
QStringList());
EXPECT_EQ(shortAppId, application->appId());
}
TEST_F(ApplicationManagerTests,startApplicationSupportsLongAppId)
{
using namespace ::testing;
const QString longAppId("com.canonical.test_test_0.1.235");
const QString shortAppId("com.canonical.test_test");
EXPECT_CALL(*taskController, start(_, _)).Times(1);
EXPECT_CALL(*taskController, findDesktopFileForAppId(shortAppId)).Times(1);
EXPECT_CALL(desktopFileReaderFactory, createInstance(_, _)).Times(1);
auto application = applicationManager.startApplication(
longAppId,
QStringList());
EXPECT_EQ(shortAppId, application->appId());
}
TEST_F(ApplicationManagerTests,testAppIdGuessFromDesktopFileName)
{
using namespace ::testing;
const pid_t procId = 5921;
QString appId("sudoku-app");
QString cmdLine = QString("/usr/bin/my-app --desktop_file_hint=/usr/share/click/preinstalled/com.ubuntu.sudoku/1.0.180/%1.desktop").arg(appId);
EXPECT_CALL(procInfo,command_line(procId))
.Times(1)
.WillOnce(Return(qPrintable(cmdLine)));
bool authed = true;
applicationManager.authorizeSession(procId, authed);
Application *app = applicationManager.findApplication(appId);
EXPECT_EQ(true, authed);
EXPECT_NE(app, nullptr);
EXPECT_EQ(appId, app->appId());
}
TEST_F(ApplicationManagerTests,testAppIdGuessFromDesktopFileNameWithLongAppId)
{
using namespace ::testing;
const pid_t procId = 5921;
QString shortAppId("com.ubuntu.desktop_desktop");
QString cmdLine = QString("/usr/bin/my-app --desktop_file_hint=/usr/share/applications/%1_1.0.180.desktop").arg(shortAppId);
EXPECT_CALL(procInfo,command_line(procId))
.Times(1)
.WillOnce(Return(qPrintable(cmdLine)));
bool authed = true;
applicationManager.authorizeSession(procId, authed);
Application *app = applicationManager.findApplication(shortAppId);
EXPECT_EQ(true, authed);
EXPECT_NE(app, nullptr);
EXPECT_EQ(shortAppId, app->appId());
}
TEST_F(ApplicationManagerTests,bug_case_1281075_session_ptrs_always_distributed_to_last_started_app)
{
using namespace ::testing;
const pid_t first_procId = 5921;
const pid_t second_procId = 5922;
const pid_t third_procId = 5923;
std::shared_ptr aSurface(nullptr);
const char first_app_id[] = "app1";
QByteArray first_cmdLine( "/usr/bin/app1 --desktop_file_hint=app1");
const char second_app_id[] = "app2";
QByteArray second_cmdLine( "/usr/bin/app2--desktop_file_hint=app2");
const char third_app_id[] = "app3";
QByteArray third_cmdLine( "/usr/bin/app3 --desktop_file_hint=app3");
EXPECT_CALL(procInfo,command_line(first_procId))
.Times(1)
.WillOnce(Return(first_cmdLine));
ON_CALL(*taskController,appIdHasProcessId(_,_)).WillByDefault(Return(false));
EXPECT_CALL(procInfo,command_line(second_procId))
.Times(1)
.WillOnce(Return(second_cmdLine));
EXPECT_CALL(procInfo,command_line(third_procId))
.Times(1)
.WillOnce(Return(third_cmdLine));
bool authed = true;
std::shared_ptr first_session = std::make_shared("Oo", first_procId);
std::shared_ptr second_session = std::make_shared("oO", second_procId);
std::shared_ptr third_session = std::make_shared("OO", third_procId);
applicationManager.authorizeSession(first_procId, authed);
applicationManager.authorizeSession(second_procId, authed);
applicationManager.authorizeSession(third_procId, authed);
onSessionStarting(first_session);
onSessionStarting(third_session);
onSessionStarting(second_session);
Application * firstApp = applicationManager.findApplication(first_app_id);
Application * secondApp = applicationManager.findApplication(second_app_id);
Application * thirdApp = applicationManager.findApplication(third_app_id);
EXPECT_EQ(first_session, firstApp->session()->session());
EXPECT_EQ(second_session, secondApp->session()->session());
EXPECT_EQ(third_session, thirdApp->session()->session());
}
TEST_F(ApplicationManagerTests,two_session_on_one_application)
{
using namespace ::testing;
const pid_t a_procId = 5921;
const char an_app_id[] = "some_app";
QByteArray a_cmd( "/usr/bin/app1 --desktop_file_hint=some_app");
ON_CALL(procInfo,command_line(_)).WillByDefault(Return(a_cmd));
ON_CALL(*taskController,appIdHasProcessId(_,_)).WillByDefault(Return(false));
bool authed = true;
std::shared_ptr