Warning, /plasma/discover/discover/autotests/toplevels.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick
0002 import QtTest
0003 import org.kde.discover as Discover
0004 
0005 DiscoverTest {
0006     onReset: {
0007         appRoot.currentTopLevel = appRoot.topBrowsingComp
0008     }
0009 
0010     function test_openCategory() {
0011         var categoryName = "dummy 3";
0012         app.openCategory(categoryName);
0013         verify(appRoot.stack.currentItem, "has a page");
0014         compare(appRoot.stack.currentItem.title, categoryName, "same title");
0015         verify(waitForRendering())
0016 
0017         categoryName = "dummy 4";
0018         app.openCategory(categoryName);
0019         verify(appRoot.stack.currentItem, "has a page");
0020         compare(appRoot.stack.currentItem.title, categoryName, "same title");
0021         verify(waitForRendering())
0022     }
0023 
0024     function test_openHome() {
0025         var drawer = appRoot.globalDrawer;
0026         drawer.actions[0].children[2].trigger()
0027         compare(appRoot.stack.currentItem.title, "dummy 3", "same title");
0028 
0029         app.openMode("Browsing");
0030 
0031         compare(appRoot.stack.currentItem.title, "Featured", "same title");
0032         compare(drawer.currentSubMenu, null)
0033     }
0034 
0035     function test_navigateThenUpdate() {
0036         var drawer = appRoot.globalDrawer;
0037         var firstitem = drawer.actions[0].children[2]
0038         var updateButton;
0039         chooseChild(drawer, function(object) {
0040             if (object.objectName === "updateButton") {
0041                 updateButton = object;
0042                 return true
0043             }
0044             return false;
0045         });
0046 
0047         firstitem.trigger()
0048         verify(updateButton.enabled)
0049         updateButton.clicked()
0050 
0051         compare(appRoot.currentTopLevel, appRoot.topUpdateComp, "correct component, updates");
0052     }
0053 
0054     function test_update() {
0055         app.openMode("Update");
0056 
0057         var updatePage = appRoot.stack.currentItem;
0058         compare(typeName(updatePage), "UpdatesPage")
0059         compare(updatePage.state, "has-updates", "to update")
0060         var action = updatePage.actions.main
0061         verify(action);
0062         action.triggered(updatePage);
0063         compare(updatePage.state, "progressing", "updating")
0064 
0065         //make sure the window doesn't close while updating
0066         verify(appRoot.visible);
0067         verify(waitForRendering())
0068         appRoot.close()
0069         verify(appRoot.visible);
0070 
0071         while(updatePage.state !== "now-uptodate")
0072             waitForSignal(updatePage, "stateChanged")
0073         compare(Discover.ResourcesModel.updatesCount, 0, "should be up to date")
0074     }
0075 
0076     function test_search() {
0077         app.openMode("Browsing");
0078         app.openSearch("cocacola")
0079         while(!isType(appRoot.stack.currentItem, "ApplicationsListPage"))
0080             verify(waitForSignal(appRoot.stack, "currentItemChanged"))
0081         var listPage = appRoot.stack.currentItem
0082         while(listPage.count>0)
0083             verify(waitForSignal(listPage, "countChanged"))
0084         compare(listPage.count, 0)
0085         compare(listPage.search, "cocacola")
0086         app.openSearch("dummy")
0087         listPage = appRoot.stack.currentItem
0088         compare(listPage.search, "dummy")
0089 //     compare(listPage.count, Discover.ResourcesModel.rowCount()/2)
0090     }
0091 
0092     function test_modes() {
0093         app.openMode("Browsing");
0094         compare(appRoot.currentTopLevel, appRoot.topBrowsingComp, "correct component, browsing");
0095         verify(waitForRendering())
0096 
0097         app.openMode("Installed");
0098         compare(appRoot.currentTopLevel, appRoot.topInstalledComp, "correct component, installed");
0099         verify(waitForRendering())
0100 
0101         app.openMode("Update");
0102         compare(appRoot.currentTopLevel, appRoot.topUpdateComp, "correct component, updates");
0103         verify(waitForRendering())
0104 
0105         app.openMode("Sources");
0106         compare(appRoot.currentTopLevel, appRoot.topSourcesComp, "correct component, sources");
0107         verify(waitForRendering())
0108     }
0109 }