on xenial help sign in
add tests for the spread
9e2fd34Michael Zanetti
qml/Stages/PhoneStage.qml+3−2
@@ -133,7 +133,7 @@ Item {
133 // Mir signals us that the newly started app has gotten focus before it paints something on the screen
133 // Mir signals us that the newly started app has gotten focus before it paints something on the screen
134 // This would result in the old app surface becoming visible for a bit.
134 // This would result in the old app surface becoming visible for a bit.
135 // FIXME: change appManager to only change the focusedApplicationId when the surface is ready to be shown.
135 // FIXME: change appManager to only change the focusedApplicationId when the surface is ready to be shown.
136− interval: 1500
136+ interval: 0//1500
137 repeat: false
137 repeat: false
138 onTriggered: {
138 onTriggered: {
139 priv.applicationStarting = false;
139 priv.applicationStarting = false;
@@ -270,6 +270,7 @@ Item {
270
270
271 Flickable {
271 Flickable {
272 id: spreadView
272 id: spreadView
273+ objectName: "spreadView"
273 anchors.fill: parent
274 anchors.fill: parent
274 visible: spreadDragArea.status == DirectionalDragArea.Recognized || stage > 1 || snapAnimation.running
275 visible: spreadDragArea.status == DirectionalDragArea.Recognized || stage > 1 || snapAnimation.running
275 contentWidth: spreadRow.width - shift
276 contentWidth: spreadRow.width - shift
@@ -378,6 +379,7 @@ Item {
378 model: ApplicationManager
379 model: ApplicationManager
379 delegate: TransformedSpreadDelegate {
380 delegate: TransformedSpreadDelegate {
380 id: appDelegate
381 id: appDelegate
382+ objectName: "appDelegate" + index
381 startAngle: 45
383 startAngle: 45
382 endAngle: 5
384 endAngle: 5
383 startScale: 1.1
385 startScale: 1.1
@@ -400,7 +402,6 @@ Item {
400 if (index == 1 && spreadView.stage < 2) {
402 if (index == 1 && spreadView.stage < 2) {
401 tileProgress += spreadView.tileDistance / spreadView.width
403 tileProgress += spreadView.tileDistance / spreadView.width
402 }
404 }
403− print("returning tile progress!!!", tileProgress, spreadView.shiftedContentX, spreadView.shift, spreadView.contentX )
404 return tileProgress;
405 return tileProgress;
405 }
406 }
406
407
tests/mocks/Unity/Application/ApplicationManager.cpp+26−1
@@ -35,6 +35,7 @@ ApplicationManager::ApplicationManager(QObject *parent)
35 , m_mainStage(0)
35 , m_mainStage(0)
36 , m_sideStageComponent(0)
36 , m_sideStageComponent(0)
37 , m_sideStage(0)
37 , m_sideStage(0)
38+ , m_rightMargin(0)
38{
39{
39 buildListOfAvailableApplications();
40 buildListOfAvailableApplications();
40}
41}
@@ -336,10 +337,12 @@ void ApplicationManager::generateQmlStrings(ApplicationInfo *application)
336 "Image {\n"
337 "Image {\n"
337 " anchors.fill: parent\n"
338 " anchors.fill: parent\n"
338 " anchors.topMargin: %1\n"
339 " anchors.topMargin: %1\n"
340+ " anchors.rightMargin: %2\n"
339− " source: \"file://%2/Dash/graphics/phone/screenshots/%3.png\"\n"
341+ " source: \"file://%3/Dash/graphics/phone/screenshots/%4.png\"\n"
340 " smooth: true\n"
342 " smooth: true\n"
341 " fillMode: Image.PreserveAspectCrop\n"
343 " fillMode: Image.PreserveAspectCrop\n"
342 "}").arg(topMargin)
344 "}").arg(topMargin)
345+ .arg(m_rightMargin)
343 .arg(qmlDirectory())
346 .arg(qmlDirectory())
344 .arg(application->icon().toString());
347 .arg(application->icon().toString());
345 application->setWindowQml(windowQml);
348 application->setWindowQml(windowQml);
@@ -568,3 +571,25 @@ void ApplicationManager::createSideStage()
568 m_sideStage->setParentItem(shell);
571 m_sideStage->setParentItem(shell);
569 m_sideStage->setFlag(QQuickItem::ItemHasContents, false);
572 m_sideStage->setFlag(QQuickItem::ItemHasContents, false);
570}
573}
574+
575+QStringList ApplicationManager::availableApplications()
576+{
577+ QStringList appIds;
578+ Q_FOREACH(ApplicationInfo *app, m_availableApplications) {
579+ appIds << app->appId();
580+ }
581+ return appIds;
582+}
583+
584+int ApplicationManager::rightMargin() const
585+{
586+ return m_rightMargin;
587+}
588+
589+void ApplicationManager::setRightMargin(int rightMargin)
590+{
591+ m_rightMargin = rightMargin;
592+ Q_FOREACH(ApplicationInfo *app, m_availableApplications) {
593+ generateQmlStrings(app);
594+ }
595+}
tests/mocks/Unity/Application/ApplicationManager.h+11
@@ -45,6 +45,10 @@ class ApplicationManager : public ApplicationManagerInterface {
45
45
46 Q_PROPERTY(bool fake READ fake CONSTANT)
46 Q_PROPERTY(bool fake READ fake CONSTANT)
47
47
48+ // Only for testing
49+ // This can be used to place some controls to right, like make tryPhoneStage for example
50+ Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin)
51+
48 public:
52 public:
49 ApplicationManager(QObject *parent = NULL);
53 ApplicationManager(QObject *parent = NULL);
50 virtual ~ApplicationManager();
54 virtual ~ApplicationManager();
@@ -99,6 +103,11 @@ class ApplicationManager : public ApplicationManagerInterface {
99 bool suspended() const;
103 bool suspended() const;
100 void setSuspended(bool suspended);
104 void setSuspended(bool suspended);
101
105
106+ // Only for testing
107+ Q_INVOKABLE QStringList availableApplications();
108+ int rightMargin() const;
109+ void setRightMargin(int rightMargin);
110+
102 Q_SIGNALS:
111 Q_SIGNALS:
103 void keyboardHeightChanged();
112 void keyboardHeightChanged();
104 void keyboardVisibleChanged();
113 void keyboardVisibleChanged();
@@ -124,6 +133,8 @@ class ApplicationManager : public ApplicationManagerInterface {
124 QQuickItem *m_mainStage;
133 QQuickItem *m_mainStage;
125 QQmlComponent *m_sideStageComponent;
134 QQmlComponent *m_sideStageComponent;
126 QQuickItem *m_sideStage;
135 QQuickItem *m_sideStage;
136+
137+ int m_rightMargin;
127};
138};
128
139
129Q_DECLARE_OPERATORS_FOR_FLAGS(ApplicationManager::ExecFlags)
140Q_DECLARE_OPERATORS_FOR_FLAGS(ApplicationManager::ExecFlags)
tests/mocks/Unity/Application/ApplicationScreenshotProvider.cpp+1−1
@@ -57,7 +57,7 @@ QImage ApplicationScreenshotProvider::requestImage(const QString &imageId, QSize
57 Q_FOREACH (QWindow *win, unity->allWindows()) {
57 Q_FOREACH (QWindow *win, unity->allWindows()) {
58 QQuickWindow *quickWin = qobject_cast<QQuickWindow*>(win);
58 QQuickWindow *quickWin = qobject_cast<QQuickWindow*>(win);
59 if (quickWin) {
59 if (quickWin) {
60− image = image.scaledToWidth(quickWin->width());
60+ image = image.scaledToWidth(quickWin->width() - m_appManager->rightMargin());
61 }
61 }
62 }
62 }
63
63
tests/qmltests/CMakeLists.txt+1−1
@@ -89,6 +89,6 @@ add_qml_test(Panel/Indicators DefaultIndicatorPage IMPORT_PATHS ${CMAKE_BINARY_D
89 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
89 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
90add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
90add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
91add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
91add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS} ${CMAKE_BINARY_DIR}/plugins)
92−add_qml_test(SideStage SideStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
92+add_qml_test(Stages PhoneStage IMPORT_PATHS ${qmltest_DEFAULT_IMPORT_PATHS}
93 ${CMAKE_BINARY_DIR}/tests/mocks
93 ${CMAKE_BINARY_DIR}/tests/mocks
94 ${CMAKE_BINARY_DIR}/plugins)
94 ${CMAKE_BINARY_DIR}/plugins)