| 1 | /* |
| 2 | * Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd. |
| 3 | * |
| 4 | * Author: ZhangYong <[email protected]> |
| 5 | * |
| 6 | * Maintainer: ZhangYong <[email protected]> |
| 7 | * |
| 8 | * This program is free software: you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation, either version 3 of the License, or |
| 11 | * any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | #include <gtest/gtest.h> |
| 22 | #include <gmock/gmock-matchers.h> |
| 23 | |
| 24 | #include <QMap> |
| 25 | #include <QTestEventList> |
| 26 | #include <QObject> |
| 27 | #include <QDialog> |
| 28 | #include <QStringList> |
| 29 | |
| 30 | #include <DSearchEdit> |
| 31 | #include <DFileDialog> |
| 32 | |
| 33 | #define private public |
| 34 | #define protected public |
| 35 | |
| 36 | #include "mainwindow.h" |
| 37 | #include "importtimelineview.h" |
| 38 | #include "albumcreatedialog.h" |
| 39 | #include "test_qtestDefine.h" |
| 40 | #include "imginfodialog.h" |
| 41 | #include "imageengine/imageengineapi.h" |
| 42 | #include "viewpanel.h" |
| 43 | #include "ac-desktop-define.h" |
| 44 | |
| 45 | #include <stub-tool/cpp-stub/stub.h> |
| 46 | #include <stub-tool/stub-ext/stubext.h> |
| 47 | |
| 48 | |
| 49 | TEST(ImportTimeLineView, getIBaseHeight_test) |
| 50 | { |
| 51 | TEST_CASE_NAME("getIBaseHeight_test") |
| 52 | MainWindow *w = dApp->getMainWindow(); |
| 53 | w->albumBtnClicked(); |
| 54 | QTest::qWait(500); |
| 55 | |
| 56 | ImportTimeLineView *impTimeline = w->m_pAlbumview->m_pImpTimeLineView; |
| 57 | int a = 0; |
| 58 | stub_ext::StubExt stu; |
| 59 | stu.set_lamda(ADDR(DSlider, value), [&a]() { |
| 60 | return a++; |
| 61 | }); |
| 62 | for (int i = 0; i < 10; i++) { |
| 63 | impTimeline->getIBaseHeight(); |
| 64 | } |
| 65 | impTimeline->onSuspensionChoseBtnClicked(); |
| 66 | impTimeline->slotNoPicOrNoVideo(true); |
| 67 | impTimeline->selectPaths(); |
| 68 | QTest::qWait(500); |
| 69 | } |
| 70 | |
| 71 | |
| 72 | TEST(ImportTimeLineView, test_func) |
| 73 | { |
| 74 | TEST_CASE_NAME("test_func") |
| 75 | MainWindow *w = dApp->getMainWindow(); |
| 76 | w->albumBtnClicked(); |
| 77 | QTest::qWait(500); |
| 78 | |
| 79 | w->allPicBtnClicked(); |
| 80 | w->albumBtnClicked(); |
| 81 | QTest::qWait(500); |
| 82 | } |
| 83 | |
| 84 | TEST(ImportTimeLineView, on_KeyEvent_test) |
| 85 | { |
| 86 | TEST_CASE_NAME("on_KeyEvent_test") |
| 87 | MainWindow *w = dApp->getMainWindow(); |
| 88 | w->albumBtnClicked(); |
| 89 | QTest::qWait(500); |
| 90 | //todo |
| 91 | // ImportTimeLineView *impTimeline = w->m_pAlbumview->m_pImpTimeLineView; |
| 92 | // impTimeline->on_KeyEvent(Qt::Key_PageDown); |
| 93 | // QTest::qWait(100); |
| 94 | // impTimeline->on_KeyEvent(Qt::Key_PageUp); |
| 95 | // QTest::qWait(500); |
| 96 | } |
| 97 | |
| 98 | TEST(ImportTimeLineView, resizeHand_test) |
| 99 | { |
| 100 | TEST_CASE_NAME("resizeHand_test") |
| 101 | MainWindow *w = dApp->getMainWindow(); |
| 102 | w->albumBtnClicked(); |
| 103 | QTest::qWait(500); |
| 104 | ImportTimeLineView *impTimeline = w->m_pAlbumview->m_pImpTimeLineView; |
| 105 | } |
| 106 | |
| 107 | TEST(ImportTimeLineView, thumbnaillistViewSlot_test) |
| 108 | { |
| 109 | TEST_CASE_NAME("thumbnaillistViewSlot_test") |
| 110 | QTest::qWait(500); |
| 111 | MainWindow *w = dApp->getMainWindow(); |
| 112 | QTestEventList event; |
| 113 | event.addMouseClick(Qt::MouseButton::LeftButton); |
| 114 | event.simulate(w->getButG()->button(2)); |
| 115 | event.clear(); |
| 116 | QTest::qWait(300); |
| 117 | AlbumView *a = w->m_pAlbumview; |
| 118 | event.addMousePress(Qt::MouseButton::LeftButton, Qt::NoModifier, QPoint(10, 10)); |
| 119 | event.addMouseRelease(Qt::MouseButton::LeftButton, Qt::NoModifier, QPoint(10, 10)); |
| 120 | event.simulate(a->m_pLeftListView->m_pPhotoLibListView->viewport()); |
| 121 | QTest::qWait(1000); |
| 122 | } |
| 123 | |
| 124 | //已导入页面再次导入图片 |
| 125 | TEST(ImportTimeLineView, Picimport) |
| 126 | { |
| 127 | TEST_CASE_NAME("load") |
| 128 | QStringList list; |
| 129 | QStringList listtemp = QStandardPaths::standardLocations(QStandardPaths::HomeLocation); |
| 130 | if (listtemp.size() > 0) { |
| 131 | list << listtemp.at(0) + "/second"; |
| 132 | } |
| 133 | |
| 134 | qDebug() << "Picture count = " << list.size() << list.at(0); |
| 135 | MainWindow *w = dApp->getMainWindow(); |
| 136 | w->getButG(); |
| 137 | w->allPicBtnClicked(); |
| 138 | |
| 139 | AllPicView *allpicview = w->m_pAllPicView; |
| 140 | ImageEngineApi::instance()->ImportImagesFromFileList(list, "", allpicview, true); |
| 141 | allpicview->update(); |
| 142 | QTest::qWait(2000); |
| 143 | |
| 144 | QTestEventList event; |
| 145 | |
| 146 | event.addMouseClick(Qt::MouseButton::LeftButton); |
| 147 | event.simulate(w->getButG()->button(1)); |
| 148 | QTest::qWait(300); |
| 149 | event.simulate(w->getButG()->button(2)); |
| 150 | QTest::qWait(300); |
| 151 | event.simulate(w->getButG()->button(0)); |
| 152 | event.clear(); |
| 153 | QTest::qWait(300); |
| 154 | ASSERT_TRUE(w != nullptr); |
| 155 | } |