on xenial help sign in
Move resources required by the Unity.Application mock inside it
3714198Michał Sawicz
CMakeLists.txt+2−1
@@ -13,8 +13,9 @@ endif()
13
13
14set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
14set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
15
15
16−# Instruct CMake to run moc automatically when needed.
16+# Instruct CMake to run moc and rcc automatically when needed.
17set(CMAKE_AUTOMOC ON)
17set(CMAKE_AUTOMOC ON)
18+set(CMAKE_AUTORCC ON)
18
19
19# enable QML debugging
20# enable QML debugging
20string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) # Build types should always be lowercase but sometimes they are not.
21string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) # Build types should always be lowercase but sometimes they are not.
tests/mocks/Unity/Application/CMakeLists.txt+1
@@ -16,6 +16,7 @@ set(FakeUnityApplicationQml_SOURCES
16 UbuntuKeyboardInfo.cpp
16 UbuntuKeyboardInfo.cpp
17 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
17 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
18 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
18 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
19+ resources/surfaces.qrc
19)
20)
20
21
21add_library(FakeUnityApplicationQml MODULE ${FakeUnityApplicationQml_SOURCES})
22add_library(FakeUnityApplicationQml MODULE ${FakeUnityApplicationQml_SOURCES})
tests/mocks/Unity/Application/MirSurfaceItem.cpp+2−10
@@ -31,7 +31,7 @@ MirSurfaceItem::MirSurfaceItem(const QString& name,
31 MirSurfaceItem::Type type,
31 MirSurfaceItem::Type type,
32 MirSurfaceItem::State state,
32 MirSurfaceItem::State state,
33 const QUrl& screenshot,
33 const QUrl& screenshot,
34− const QString &qmlFilePath,
34+ const QUrl& qmlFileUrl,
35 QQuickItem *parent)
35 QQuickItem *parent)
36 : QQuickItem(parent)
36 : QQuickItem(parent)
37 , m_session(nullptr)
37 , m_session(nullptr)
@@ -62,15 +62,7 @@ MirSurfaceItem::MirSurfaceItem(const QString& name,
62 QQuickView *quickView =
62 QQuickView *quickView =
63 qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
63 qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
64
64
65− QString qmlComponentFilePath;
66− if (!qmlFilePath.isEmpty()) {
67− qmlComponentFilePath.append(qmlFilePath);
68− } else {
69− qmlComponentFilePath = QString("%1/Unity/Application/MirSurfaceItem.qml")
70− .arg(mockPluginsDir());
71− }
72−
73− m_qmlContentComponent = new QQmlComponent(quickView->engine(), qmlComponentFilePath);
65+ m_qmlContentComponent = new QQmlComponent(quickView->engine(), qmlFileUrl);
74
66
75 switch (m_qmlContentComponent->status()) {
67 switch (m_qmlContentComponent->status()) {
76 case QQmlComponent::Ready:
68 case QQmlComponent::Ready:
tests/mocks/Unity/Application/MirSurfaceItem.h+1−1
@@ -118,7 +118,7 @@ private:
118 Type type,
118 Type type,
119 State state,
119 State state,
120 const QUrl& screenshot,
120 const QUrl& screenshot,
121− const QString &qmlFilePath = QString(),
121+ const QUrl& qmlFilePath = QUrl("qrc:///Unity/Application/MirSurfaceItem.qml"),
122 QQuickItem *parent = 0);
122 QQuickItem *parent = 0);
123
123
124 void createQmlContentItem();
124 void createQmlContentItem();
tests/mocks/Unity/Application/SurfaceManager.cpp+2−8
@@ -79,18 +79,12 @@ MirSurfaceItem *SurfaceManager::inputMethodSurface()
79{
79{
80 if (!m_virtualKeyboard) {
80 if (!m_virtualKeyboard) {
81
81
82− QString screenshotPath = QString("file://%1/Dash/graphics/phone/screenshots/vkb_portrait.png")
83− .arg(qmlDirectory());
84−
85− QString qmlFilePath = QString("%1/Unity/Application/VirtualKeyboard.qml")
86− .arg(mockPluginsDir());
87−
88 m_virtualKeyboard = new MirSurfaceItem(
82 m_virtualKeyboard = new MirSurfaceItem(
89 "input-method",
83 "input-method",
90 MirSurfaceItem::InputMethod,
84 MirSurfaceItem::InputMethod,
91 MirSurfaceItem::Minimized,
85 MirSurfaceItem::Minimized,
92− screenshotPath,
86+ QUrl("qrc:///Unity/Application/vkb_portrait.png"),
93− qmlFilePath);
87+ QUrl("qrc:///Unity/Application/VirtualKeyboard.qml"));
94 Q_EMIT surfaceCreated(m_virtualKeyboard);
88 Q_EMIT surfaceCreated(m_virtualKeyboard);
95 }
89 }
96 return m_virtualKeyboard;
90 return m_virtualKeyboard;
tests/mocks/Unity/Application/MirSurfaceItem.qml → tests/mocks/Unity/Application/resources/MirSurfaceItem.qmlrenamed

The content is the same.

tests/mocks/Unity/Application/VirtualKeyboard.qml → tests/mocks/Unity/Application/resources/VirtualKeyboard.qmlrenamed

The content is the same.

tests/mocks/Unity/Application/resources/surfaces.qrcnew file+7
@@ -0,0 +1,7 @@
1+<RCC>
2+ <qresource prefix="/Unity/Application">
3+ <file>VirtualKeyboard.qml</file>
4+ <file>MirSurfaceItem.qml</file>
5+ <file>vkb_portrait.png</file>
6+ </qresource>
7+</RCC>
tests/mocks/Unity/Application/resources/vkb_portrait.pngnew file

Binary file not shown.