| 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 <QTestEventList> |
| 25 | #include <QString> |
| 26 | #include <QTestEventList> |
| 27 | |
| 28 | #define private public |
| 29 | #define protected public |
| 30 | |
| 31 | #include "leftlistview.h" |
| 32 | #include "application.h" |
| 33 | #include "frame/mainwidget.h" |
| 34 | #include "module/view/navigationwidget.h" |
| 35 | #include "module/view/scen/graphicsitem.h" |
| 36 | #include "searchview/searchview.h" |
| 37 | #include "module/view/scen/imageview.h" |
| 38 | #include "gio-qt/dgiovolumemanager.h" |
| 39 | #include "mainwindow.h" |
| 40 | #include "albumview.h" |
| 41 | #include "baseutils.h" |
| 42 | #include "dbmanager.h" |
| 43 | #include "albumcreatedialog.h" |
| 44 | #include "../test_qtestDefine.h" |
| 45 | #include "ac-desktop-define.h" |
| 46 | #include "mock_mount.h" |
| 47 | |
| 48 | #include <QMovie> |
| 49 | |
| 50 | #include <stub-tool/cpp-stub/stub.h> |
| 51 | #include <stub-tool/stub-ext/stubext.h> |
| 52 | |
| 53 | TEST(AlbumView, keyboard) |
| 54 | { |
| 55 | TEST_CASE_NAME("keyboard") |
| 56 | MainWindow *w = dApp->getMainWindow(); |
| 57 | QTestEventList e; |
| 58 | e.addMouseClick(Qt::MouseButton::LeftButton); |
| 59 | e.simulate(w->getButG()->button(2)); |
| 60 | e.clear(); |
| 61 | QTest::qWait(3000); |
| 62 | w->albumBtnClicked(); |
| 63 | AlbumLeftTabItem *pAlbumLeftTabItem1 = w->m_pAlbumview->findChildren<AlbumLeftTabItem *>().at(0); |
| 64 | if (pAlbumLeftTabItem1) { |
| 65 | pAlbumLeftTabItem1->setFocus(); |
| 66 | QPoint p = pAlbumLeftTabItem1->pos(); |
| 67 | e.addMouseMove(p, 50); |
| 68 | e.addKeyClick(Qt::Key_Up, Qt::NoModifier, 50); |
| 69 | e.addKeyClick(Qt::Key_Down, Qt::NoModifier, 50); |
| 70 | e.addKeyClick(Qt::Key_Left, Qt::NoModifier, 50); |
| 71 | e.addKeyClick(Qt::Key_Right, Qt::NoModifier, 50); |
| 72 | e.simulate(w); |
| 73 | QTest::qWait(300); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | |
| 78 | TEST(AlbumView, deleteAll) |
| 79 | { |
| 80 | TEST_CASE_NAME("deleteAll") |
| 81 | ImageEngineApi::instance()->loadFirstPageThumbnails(50); |
| 82 | QTest::qWait(500); |
| 83 | MainWindow *w = dApp->getMainWindow(); |
| 84 | w->loadZoomRatio(); |
| 85 | } |
| 86 | |
| 87 | TEST(AlbumView, removeTestImagesInfo) |
| 88 | { |
| 89 | TEST_CASE_NAME("removeTestImagesInfo") |
| 90 | QStringList image_list; |
| 91 | auto finfos = utils::image::getImagesAndVideoInfo(testPath_test); |
| 92 | auto finfos1 = utils::image::getImagesAndVideoInfo(testPath_test, false); |
| 93 | auto pixmap = utils::image::getDamagePixmap(true); |
| 94 | for (auto info : finfos) { |
| 95 | image_list << info.absoluteFilePath(); |
| 96 | } |
| 97 | QStringList res = DBManager::instance()->getAllPaths(); |
| 98 | QTest::qWait(1000); |
| 99 | DBManager::instance()->removeImgInfos(res); |
| 100 | DBImgInfoList dbinfos; |
| 101 | for (auto i : image_list) { |
| 102 | DBImgInfo info; |
| 103 | info.filePath = i; |
| 104 | dbinfos << info; |
| 105 | } |
| 106 | MainWindow *w = dApp->getMainWindow(); |
| 107 | AllPicView *a = w->m_pAllPicView; |
| 108 | a->updatePicsThumbnailView(); |
| 109 | QTest::qWait(1000); |
| 110 | } |
| 111 | |
| 112 | TEST(AlbumView, clickImportViewBtn) |
| 113 | { |
| 114 | TEST_CASE_NAME("clickImportViewBtn") |
| 115 | MainWindow *w = dApp->getMainWindow(); |
| 116 | // AllPicView *a = w->m_pAllPicView; |
| 117 | |
| 118 | QStringList image_list; |
| 119 | auto finfos = utils::image::getImagesAndVideoInfo(testPath_test); |
| 120 | for (auto info : finfos) { |
| 121 | image_list << info.absoluteFilePath(); |
| 122 | } |
| 123 | QTest::qWait(500); |
| 124 | |
| 125 | if (image_list.size() > 0) |
| 126 | ImageEngineApi::instance()->insertImage(image_list.first(), ""); |
| 127 | } |
| 128 | |
| 129 | TEST(AlbumView, ini) |
| 130 | { |
| 131 | TEST_CASE_NAME("ini") |
| 132 | MainWindow *w = dApp->getMainWindow(); |
| 133 | w->loadZoomRatio(); |
| 134 | |
| 135 | QPoint pos(10, 10); |
| 136 | QTestEventList event; |
| 137 | event.addMouseMove(pos); |
| 138 | event.addMouseClick(Qt::MouseButton::LeftButton, Qt::NoModifier, pos); |
| 139 | event.simulate(w->getButG()->button(0)); |
| 140 | event.clear(); |
| 141 | QTest::qWait(500); |
| 142 | |
| 143 | event.addMouseMove(pos); |
| 144 | event.addMouseClick(Qt::MouseButton::LeftButton, Qt::NoModifier, pos); |
| 145 | event.simulate(w->getButG()->button(1)); |
| 146 | event.clear(); |
| 147 | QTest::qWait(500); |
| 148 | |
| 149 | event.addMouseMove(pos); |
| 150 | event.addMouseClick(Qt::MouseButton::LeftButton, Qt::NoModifier, pos); |
| 151 | event.simulate(w->getButG()->button(2)); |
| 152 | event.clear(); |
| 153 | QTest::qWait(500); |
| 154 | } |
| 155 | |
| 156 | TEST(AlbumView, iniAlbum) |
| 157 | { |
| 158 | TEST_CASE_NAME("iniAlbum") |
| 159 | QTest::qWait(500); |
| 160 | MainWindow *w = dApp->getMainWindow(); |
| 161 | w->showEvent(nullptr); |
| 162 | QTestEventList event; |
| 163 | event.addMouseClick(Qt::MouseButton::LeftButton); |
| 164 | event.simulate(w->getButG()->button(2)); |
| 165 | event.clear(); |
| 166 | QTest::qWait(500); |
| 167 | |
| 168 | AlbumView *a = w->m_pAlbumview; |
| 169 | int width = a->m_pStatusBar->m_pSlider->slider()->width(); |
| 170 | QPoint pos(width / 10 * a->m_pStatusBar->m_pSlider->slider()->sliderPosition(), 10); |
| 171 | event.addMousePress(Qt::LeftButton, Qt::NoModifier, pos); |
| 172 | pos = pos - QPoint(200, 0); |
| 173 | event.addMouseMove(pos); |
| 174 | QTest::qWait(500); |
| 175 | event.simulate(a->m_pStatusBar->m_pSlider->slider()); |
| 176 | pos = QPoint(width / 10 * a->m_pStatusBar->m_pSlider->slider()->sliderPosition(), 10); |
| 177 | for (int i = 0; i < 5; i++) { |
| 178 | event.addMousePress(Qt::LeftButton, Qt::NoModifier, pos); |
| 179 | pos = pos + QPoint(20, 0); |
| 180 | event.addMouseMove(pos); |
| 181 | event.simulate(a->m_pStatusBar->m_pSlider->slider()); |
| 182 | event.clear(); |
| 183 | QTest::qWait(400); |
| 184 | } |
| 185 | pos = QPoint(width / 10 * a->m_pStatusBar->m_pSlider->slider()->sliderPosition(), 10); |
| 186 | for (int i = 0; i < 5; i++) { |
| 187 | event.addMousePress(Qt::LeftButton, Qt::NoModifier, pos); |
| 188 | pos = pos - QPoint(20, 0); |
| 189 | event.addMouseMove(pos); |
| 190 | event.simulate(a->m_pStatusBar->m_pSlider->slider()); |
| 191 | event.clear(); |
| 192 | QTest::qWait(400); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | TEST(AlbumView, createNewAlbumFromDialog) |
| 197 | { |
| 198 | TEST_CASE_NAME("createNewAlbumFromDialog") |
| 199 | MainWindow *w = dApp->getMainWindow(); |
| 200 | w->albumBtnClicked(); |
| 201 | |
| 202 | QList<QAction *> actions = w->actions(); |
| 203 | |
| 204 | AlbumImageButton *btn = w->m_pAlbumview->m_pLeftListView->m_pAddListBtn; |
| 205 | QPoint pointbtn = btn->pos(); |
| 206 | QTestEventList event; |
| 207 | event.addMouseMove(pointbtn + QPoint(1, 1), 10); |
| 208 | event.addMouseMove(pointbtn + QPoint(2, 2), 10); |
| 209 | event.addMouseClick(Qt::LeftButton, Qt::NoModifier); |
| 210 | event.addMouseMove(pointbtn + QPoint(200, 200), 10); |
| 211 | event.simulate(btn); |
| 212 | event.clear(); |
| 213 | QTest::qWait(500); |
| 214 | QList<QWidget *> widgets = w->findChildren<QWidget *>(""); |
| 215 | foreach (auto widget, widgets) { |
| 216 | if (!strcmp(widget->metaObject()->className(), "AlbumCreateDialog")) { |
| 217 | AlbumCreateDialog *temp = static_cast<AlbumCreateDialog *>(widget); |
| 218 | QPoint pos(10, 10); |
| 219 | event.addMouseMove(pos); |
| 220 | event.addMouseClick(Qt::MouseButton::LeftButton, Qt::NoModifier, pos); |
| 221 | event.simulate(temp->getButton(1)); |
| 222 | event.clear(); |
| 223 | break; |
| 224 | } |
| 225 | } |
| 226 | QTest::qWait(200); |
| 227 | emit dApp->signalM->sigCreateNewAlbumFromDialog("test-album"); |
| 228 | emit dApp->signalM->sigCreateNewAlbumFrom("test-album2"); |
| 229 | } |
| 230 | |
| 231 | TEST(AlbumView, dragPhotoToAnAlbum) |
| 232 | { |
| 233 | TEST_CASE_NAME("dragPhotoToAnAlbum") |
| 234 | MainWindow *w = dApp->getMainWindow(); |
| 235 | |
| 236 | w->albumBtnClicked(); |
| 237 | QTest::qWait(100); |
| 238 | AlbumView *a = w->m_pAlbumview; |
| 239 | // open import widget |
| 240 | QTestEventList event; |
| 241 | event.addMousePress(Qt::MouseButton::LeftButton, Qt::NoModifier, QPoint(10, 10)); |
| 242 | event.addMouseRelease(Qt::MouseButton::LeftButton, Qt::NoModifier, QPoint(10, 10)); |
| 243 | event.simulate(a->m_pLeftListView->m_pPhotoLibListView->viewport()); |
| 244 | event.clear(); |
| 245 | QTest::qWait(500); |
| 246 | |
| 247 | LeftListWidget *albumList = a->m_pLeftListView->m_pCustomizeListView; |
| 248 | a->pImportTimeLineWidget->setFocus(); |
| 249 | if (albumList->count() > 0) { |
| 250 | QList<QWidget *> widgets = a->pImportTimeLineWidget->findChildren<QWidget *>(""); |
| 251 | for (int index = 0; index < widgets.count(); index++) { |
| 252 | if (!strcmp(widgets.at(index)->metaObject()->className(), ("ThumbnailListView"))) { |
| 253 | ThumbnailListView *listview = static_cast<ThumbnailListView *>(widgets.at(index)); |
| 254 | listview->setFocus(); |
| 255 | |
| 256 | QString jpgItemPath = testPath_test + "/2k9o1m.png"; |
| 257 | QString text = "xxxxxxxxxxxxxx"; |
| 258 | QIcon icon = QIcon(":/resources/images/other/deepin-album.svg"); |
| 259 | QIcon icon_hover = QIcon(":/resources/images/other/deepin-album.svg"); |
| 260 | QByteArray itemData; |
| 261 | QDataStream dataStream(&itemData, QIODevice::WriteOnly); |
| 262 | dataStream << text << icon << icon_hover; |
| 263 | QMimeData mimedata; |
| 264 | mimedata.setData(QStringLiteral("TestListView/text-icon-icon_hover"), itemData); |
| 265 | QList<QUrl> li; |
| 266 | li.append(QUrl::fromLocalFile(jpgItemPath)); |
| 267 | mimedata.setUrls(li); |
| 268 | |
| 269 | QModelIndex model_index; |
| 270 | emit a->m_pLeftListView->m_pCustomizeListView->pressed(model_index); |
| 271 | QTest::qWait(200); |
| 272 | const QPoint pos1 = a->m_pLeftListView->m_pCustomizeListView->pos() + QPoint(90, 20); |
| 273 | qDebug() << "pos1 " << pos1; |
| 274 | QDragEnterEvent eEnter(pos1, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 275 | dApp->getDAppNew()->sendEvent(a->m_pLeftListView->m_pCustomizeListView, &eEnter); |
| 276 | QTest::qWait(200); |
| 277 | |
| 278 | QDragMoveEvent eMove(pos1, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 279 | dApp->getDAppNew()->sendEvent(a->m_pLeftListView->m_pCustomizeListView, &eMove); |
| 280 | QTest::qWait(200); |
| 281 | |
| 282 | QDropEvent e(pos1, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 283 | dApp->getDAppNew()->sendEvent(a->m_pLeftListView->m_pCustomizeListView, &e); |
| 284 | QTest::qWait(200); |
| 285 | |
| 286 | dApp->getDAppNew()->sendEvent(a->m_pLeftListView->m_pCustomizeListView, &eEnter); |
| 287 | QTest::qWait(200); |
| 288 | |
| 289 | QDragLeaveEvent eLeave; |
| 290 | dApp->getDAppNew()->sendEvent(a->m_pLeftListView->m_pCustomizeListView, &eLeave); |
| 291 | QTest::qWait(500); |
| 292 | break; |
| 293 | } |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | TEST(AlbumView, leftMenu) |
| 299 | { |
| 300 | TEST_CASE_NAME("leftMenu") |
| 301 | QTest::qWait(500); |
| 302 | MainWindow *w = dApp->getMainWindow(); |
| 303 | QTestEventList event; |
| 304 | event.addMouseClick(Qt::MouseButton::LeftButton); |
| 305 | event.simulate(w->getButG()->button(2)); |
| 306 | event.clear(); |
| 307 | QTest::qWait(300); |
| 308 | AlbumView *a = w->m_pAlbumview; |
| 309 | event.addMousePress(Qt::MouseButton::LeftButton, Qt::NoModifier, QPoint(10, 10)); |
| 310 | event.addMouseRelease(Qt::MouseButton::LeftButton, Qt::NoModifier, QPoint(10, 10)); |
| 311 | event.simulate(a->m_pLeftListView->m_pPhotoLibListView->viewport()); |
| 312 | QTest::qWait(500); |
| 313 | event.simulate(a->m_pLeftListView->m_pCustomizeListView->viewport()); |
| 314 | QTest::qWait(500); |
| 315 | dApp->getDAppNew()->processEvents(); |
| 316 | event.simulate(a->m_pLeftListView->m_pMountListWidget->viewport()); |
| 317 | QTest::qWait(500); |
| 318 | event.simulate(a->m_waitDeviceScandialog->m_closeDeviceScan); |
| 319 | QTest::qWait(500); |
| 320 | dApp->viewerTheme->setCurrentTheme(ViewerThemeManager::Light); |
| 321 | dApp->viewerTheme->setCurrentTheme(ViewerThemeManager::Dark); |
| 322 | QTest::qWait(500); |
| 323 | } |
| 324 | |
| 325 | TEST(AlbumView, iniAlbum1) |
| 326 | { |
| 327 | TEST_CASE_NAME("iniAlbum1") |
| 328 | QTest::qWait(500); |
| 329 | MainWindow *w = dApp->getMainWindow(); |
| 330 | w->showEvent(nullptr); |
| 331 | QTestEventList event; |
| 332 | event.addMouseClick(Qt::MouseButton::LeftButton); |
| 333 | event.simulate(w->getButG()->button(2)); |
| 334 | event.clear(); |
| 335 | QTest::qWait(500); |
| 336 | |
| 337 | AlbumView *a = w->m_pAlbumview; |
| 338 | int width = a->m_pStatusBar->m_pSlider->slider()->width(); |
| 339 | QPoint pos(width / 10 * a->m_pStatusBar->m_pSlider->slider()->sliderPosition(), 10); |
| 340 | event.addMousePress(Qt::LeftButton, Qt::NoModifier, pos); |
| 341 | pos = pos - QPoint(200, 0); |
| 342 | event.addMouseMove(pos); |
| 343 | QTest::qWait(500); |
| 344 | event.simulate(a->m_pStatusBar->m_pSlider->slider()); |
| 345 | pos = QPoint(width / 10 * a->m_pStatusBar->m_pSlider->slider()->sliderPosition(), 10); |
| 346 | for (int i = 0; i < 5; i++) { |
| 347 | event.addMousePress(Qt::LeftButton, Qt::NoModifier, pos); |
| 348 | pos = pos + QPoint(20, 0); |
| 349 | event.addMouseMove(pos); |
| 350 | event.simulate(a->m_pStatusBar->m_pSlider->slider()); |
| 351 | event.clear(); |
| 352 | QTest::qWait(400); |
| 353 | } |
| 354 | pos = QPoint(width / 10 * a->m_pStatusBar->m_pSlider->slider()->sliderPosition(), 10); |
| 355 | for (int i = 0; i < 5; i++) { |
| 356 | event.addMousePress(Qt::LeftButton, Qt::NoModifier, pos); |
| 357 | pos = pos - QPoint(20, 0); |
| 358 | event.addMouseMove(pos); |
| 359 | event.simulate(a->m_pStatusBar->m_pSlider->slider()); |
| 360 | event.clear(); |
| 361 | QTest::qWait(400); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | TEST(AlbumView, deleteImgRecovery) |
| 366 | { |
| 367 | TEST_CASE_NAME("deleteImgRecovery") |
| 368 | QTest::qWait(500); |
| 369 | MainWindow *w = dApp->getMainWindow(); |
| 370 | QTestEventList event; |
| 371 | event.addMouseClick(Qt::MouseButton::LeftButton); |
| 372 | event.simulate(w->getButG()->button(2)); |
| 373 | event.clear(); |
| 374 | AlbumView *a = w->m_pAlbumview; |
| 375 | a->m_currentType = COMMON_STR_TRASH; |
| 376 | a->updateRightView(); |
| 377 | ImageEngineApi::instance()->recoveryImagesFromTrash(a->m_pRightTrashThumbnailList->getFileList()); |
| 378 | } |
| 379 | |
| 380 | TEST(AlbumView, exportAlbum)//roc |
| 381 | { |
| 382 | TEST_CASE_NAME("exportAlbum") |
| 383 | // qDebug() << "AlbumView exportAlbum count = " << count_testDefine++; |
| 384 | // AlbumCreateDialog *ad = new AlbumCreateDialog; |
| 385 | // QTest::keyClicks(ad->getEdit(), "newtestalbum1"); |
| 386 | // emit ad->buttonClicked(1, ""); |
| 387 | // QTest::qWait(200); |
| 388 | // QString testPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + QDir::separator() + "test"; |
| 389 | |
| 390 | // MainWindow *w = dApp->getMainWindow(); |
| 391 | // AlbumView *a = w->m_pAlbumview; |
| 392 | // ImageEngineApi::instance()->ImportImagesFromFileList((QStringList() << testPath), "newtestalbum1", a, false); |
| 393 | // QTest::qWait(500); |
| 394 | // QStringList testImage = ImageEngineApi::instance()->get_AllImagePath(); |
| 395 | // QString exportFile = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + QDir::separator() + "exportTest"; |
| 396 | // QDir Dir(exportFile); |
| 397 | // if (!Dir.isEmpty()) { |
| 398 | // QDirIterator DirsIterator(exportFile, QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot, QDirIterator::NoIteratorFlags); |
| 399 | // while (DirsIterator.hasNext()) { |
| 400 | // if (!Dir.remove(DirsIterator.next())) { // 删除文件操作如果返回否,那它就是目录 |
| 401 | // QDir(DirsIterator.filePath()).removeRecursively(); // 删除目录本身以及它下属所有的文件及目录 |
| 402 | // } |
| 403 | // } |
| 404 | // } |
| 405 | |
| 406 | // Exporter::instance()->instance()->exportAlbum(testImage, "newtestalbum1"); |
| 407 | // Exporter::instance()->instance()->exportImage(testImage.mid(0, 1)); |
| 408 | } |
| 409 | |
| 410 | TEST(AlbumImageButton, btn) |
| 411 | { |
| 412 | TEST_CASE_NAME("btn") |
| 413 | QString pic = testPath_test + "/2k9o1m.png"; |
| 414 | AlbumImageButton *b = new AlbumImageButton(pic, pic, pic, pic, nullptr); |
| 415 | b->show(); |
| 416 | b->setPropertyPic("a", "", pic, pic, pic, pic); |
| 417 | QTestEventList e; |
| 418 | QPoint point = b->pos(); |
| 419 | e.addMouseMove(point + QPoint(1, 1), 10); |
| 420 | e.addMouseMove(point + QPoint(2, 2), 10); |
| 421 | e.addMouseMove(point + QPoint(100, 100), 10); |
| 422 | e.simulate(b); |
| 423 | b->hide(); |
| 424 | ASSERT_TRUE(b != nullptr); |
| 425 | } |
| 426 | |
| 427 | // 导入重复照片提示 |
| 428 | //TEST(AlbumView, ImportDuplicatePhotos) |
| 429 | //{ |
| 430 | // TEST_CASE_NAME("load") |
| 431 | // // albumview ImportDuplicatePhotos |
| 432 | // AlbumCreateDialog *ad = new AlbumCreateDialog; |
| 433 | // ad->show(); |
| 434 | // QTest::qWait(500); |
| 435 | // QTest::keyClicks(ad->getEdit(), "ImportDuplicatePhotosAlbum"); |
| 436 | // emit ad->buttonClicked(1, ""); |
| 437 | // QTest::qWait(200); |
| 438 | // QString testPath = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + QDir::separator() + "test"; |
| 439 | // MainWindow *w = dApp->getMainWindow(); |
| 440 | // w->albumBtnClicked(); |
| 441 | // AlbumView *a = w->m_pAlbumview; |
| 442 | // ImageEngineApi::instance()->ImportImagesFromFileList((QStringList() << testPath), "ImportDuplicatePhotosAlbum", a, false); |
| 443 | // QTest::qWait(200); |
| 444 | // ImageEngineApi::instance()->ImportImagesFromFileList((QStringList() << testPath), "ImportDuplicatePhotosAlbum", a, false); |
| 445 | // QTest::qWait(500); |
| 446 | // // allpicview ImportDuplicatePhotos |
| 447 | // w->allPicBtnClicked(); |
| 448 | // AllPicView *allpicview = w->m_pAllPicView; |
| 449 | // ImageEngineApi::instance()->ImportImagesFromFileList((QStringList() << testPath), "", allpicview, true); |
| 450 | // QTest::qWait(200); |
| 451 | // ImageEngineApi::instance()->ImportImagesFromFileList((QStringList() << testPath), "", allpicview, true); |
| 452 | // QTest::qWait(1000); |
| 453 | // // timelineview ImportDuplicatePhotos |
| 454 | // w->timeLineBtnClicked(); |
| 455 | // TimeLineView *timelineview = w->m_pTimeLineView; |
| 456 | // ImageEngineApi::instance()->ImportImagesFromFileList((QStringList() << testPath), "", timelineview, true); |
| 457 | // QTest::qWait(200); |
| 458 | // ImageEngineApi::instance()->ImportImagesFromFileList((QStringList() << testPath), "", timelineview, true); |
| 459 | // QTest::qWait(500); |
| 460 | |
| 461 | // QTestEventList e; |
| 462 | // e.addMouseClick(Qt::MouseButton::LeftButton); |
| 463 | // w->albumBtnClicked(); |
| 464 | // e.simulate(w->getButG()->button(2)); |
| 465 | // e.clear(); |
| 466 | |
| 467 | // LeftListView *leftlist = a->m_pLeftListView; |
| 468 | // DMenu *menu = leftlist->m_pMenu; |
| 469 | // QPoint point = leftlist->pos(); |
| 470 | //// QTestEventList e; |
| 471 | // e.addMouseClick(Qt::MouseButton::RightButton, Qt::NoModifier, point, 10); |
| 472 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 473 | // e.addKeyClick(Qt::Key_Enter, Qt::NoModifier, 10); |
| 474 | // e.addDelay(50); |
| 475 | // e.simulate(menu); |
| 476 | // e.clear(); |
| 477 | // QTest::qWait(100); |
| 478 | |
| 479 | // e.addMouseClick(Qt::MouseButton::RightButton, Qt::NoModifier, point, 10); |
| 480 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 481 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 482 | // e.addKeyClick(Qt::Key_Enter, Qt::NoModifier, 10); |
| 483 | // e.addDelay(50); |
| 484 | // e.simulate(menu); |
| 485 | // e.clear(); |
| 486 | // QTest::qWait(100); |
| 487 | |
| 488 | // e.addMouseClick(Qt::MouseButton::RightButton, Qt::NoModifier, point, 10); |
| 489 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 490 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 491 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 492 | // e.addKeyClick(Qt::Key_Enter, Qt::NoModifier, 10); |
| 493 | // e.addDelay(50); |
| 494 | // e.simulate(menu); |
| 495 | // e.clear(); |
| 496 | // QTest::qWait(100); |
| 497 | |
| 498 | // e.addMouseClick(Qt::MouseButton::RightButton, Qt::NoModifier, point, 10); |
| 499 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 500 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 501 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 502 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 503 | // e.addKeyClick(Qt::Key_Tab, Qt::NoModifier, 10); |
| 504 | // e.addKeyClick(Qt::Key_Enter, Qt::NoModifier, 10); |
| 505 | // e.addDelay(50); |
| 506 | // e.simulate(menu); |
| 507 | // e.clear(); |
| 508 | // QTest::qWait(100); |
| 509 | // a->hide(); |
| 510 | // leftlist->hide(); |
| 511 | //} |
| 512 | |
| 513 | TEST(LeftListView, update) |
| 514 | { |
| 515 | TEST_CASE_NAME("update") |
| 516 | LeftListView *leftlist = new LeftListView; |
| 517 | leftlist->updatePhotoListView(); |
| 518 | leftlist->updateCustomizeListView(); |
| 519 | leftlist->show(); |
| 520 | QPoint point = leftlist->pos(); |
| 521 | leftlist->showMenu(point + QPoint(2, 10)); |
| 522 | point = leftlist->m_pMenu->pos(); |
| 523 | QTestEventList e; |
| 524 | e.addMouseClick(Qt::MouseButton::LeftButton, Qt::NoModifier, point - QPoint(1, 1), 10); |
| 525 | e.simulate(leftlist); |
| 526 | e.clear(); |
| 527 | leftlist->getNewAlbumName(); |
| 528 | |
| 529 | // leftlist->onMenuClicked(act); |
| 530 | e.addKeyClick(Qt::Key_Delete, Qt::ControlModifier, 100); |
| 531 | e.simulate(leftlist); |
| 532 | e.clear(); |
| 533 | |
| 534 | QString jpgItemPath = testPath_test + "/2k9o1m.png"; |
| 535 | QString text = "xxxxxxxxxxxxxx"; |
| 536 | QIcon icon = QIcon(":/resources/images/other/deepin-album.svg"); |
| 537 | QIcon icon_hover = QIcon(":/resources/images/other/deepin-album.svg"); |
| 538 | QByteArray itemData; |
| 539 | QDataStream dataStream(&itemData, QIODevice::WriteOnly); |
| 540 | dataStream << text << icon << icon_hover; |
| 541 | QMimeData mimedata; |
| 542 | mimedata.setData(QStringLiteral("TestListView/text-icon-icon_hover"), itemData); |
| 543 | QList<QUrl> li; |
| 544 | li.append(QUrl::fromLocalFile(jpgItemPath)); |
| 545 | mimedata.setUrls(li); |
| 546 | |
| 547 | LeftListWidget *wid = new LeftListWidget; |
| 548 | QPoint pos = wid->pos(); |
| 549 | e.addMousePress(Qt::LeftButton, Qt::ControlModifier, pos, 10); |
| 550 | e.addKeyPress(Qt::Key_0, Qt::NoModifier, 10); |
| 551 | e.addKeyRelease(Qt::Key_0, Qt::NoModifier, 10); |
| 552 | e.addMouseMove(pos + QPoint(1, 1)); |
| 553 | e.addMouseMove(pos + QPoint(2, 2)); |
| 554 | e.simulate(wid); |
| 555 | e.clear(); |
| 556 | QDragMoveEvent eMove(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 557 | dApp->getDAppNew()->sendEvent(wid, &eMove); |
| 558 | QTest::qWait(200); |
| 559 | QDropEvent ed(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 560 | dApp->getDAppNew()->sendEvent(wid, &ed); |
| 561 | QTest::qWait(200); |
| 562 | } |
| 563 | |
| 564 | //TEST(AlbumView, upDataAllAlbumView) |
| 565 | //{ |
| 566 | // TEST_CASE_NAME("upDataAllAlbumView") |
| 567 | // MainWindow *w = dApp->getMainWindow(); |
| 568 | // w->albumBtnClicked(); |
| 569 | // QTest::qWait(500); |
| 570 | // QString s1; |
| 571 | // w->m_pAlbumview->updateRightNoTrashView(); |
| 572 | // w->m_pAlbumview->updateRightTrashView(); |
| 573 | // w->m_pAlbumview->updateRightImportView(); |
| 574 | // w->m_pAlbumview->updateRightMyFavoriteView(); |
| 575 | // w->m_pAlbumview->updateRightMountView(); |
| 576 | // w->m_pAlbumview->updateRightImportView(); |
| 577 | // w->m_pAlbumview->leftTabClicked(); |
| 578 | // w->m_pAlbumview->updateImportComboBox(); |
| 579 | // w->m_pAlbumview->importAllBtnClicked(); |
| 580 | // w->m_pAlbumview->importSelectBtnClicked(); |
| 581 | // w->m_pAlbumview->needUnMount(s1); |
| 582 | // w->m_pAlbumview->onKeyDelete(); |
| 583 | // w->m_pAlbumview->onKeyF2(); |
| 584 | // w->m_pAlbumview->importDialog(); |
| 585 | // w->m_pAlbumview->onWaitDialogIgnore(); |
| 586 | // w->m_pAlbumview->openImage(0); |
| 587 | //// w->m_pAlbumview->onUpdataAlbumRightTitle("timelinesview");//coredump |
| 588 | // w->m_pAlbumview->SearchReturnUpdate(); |
| 589 | // w->m_pAlbumview->onUnMountSignal(""); |
| 590 | |
| 591 | // QString jpgItemPath = testPath_test + "/2k9o1m.png"; |
| 592 | // QString text = "xxxxxxxxxxxxxx"; |
| 593 | // QIcon icon = QIcon(":/resources/images/other/deepin-album.svg"); |
| 594 | // QIcon icon_hover = QIcon(":/resources/images/other/deepin-album.svg"); |
| 595 | // QByteArray itemData; |
| 596 | // QDataStream dataStream(&itemData, QIODevice::WriteOnly); |
| 597 | // dataStream << text << icon << icon_hover; |
| 598 | // QMimeData mimedata; |
| 599 | // mimedata.setData(QStringLiteral("TestListView/text-icon-icon_hover"), itemData); |
| 600 | // QList<QUrl> li; |
| 601 | // li.append(QUrl::fromLocalFile(jpgItemPath)); |
| 602 | // mimedata.setUrls(li); |
| 603 | |
| 604 | // QPoint pos = w->m_pAlbumview->pos(); |
| 605 | // QDragMoveEvent eMove(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 606 | // dApp->getDAppNew()->sendEvent(w->m_pAlbumview, &eMove); |
| 607 | // QTest::qWait(200); |
| 608 | // QDropEvent ed(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 609 | // dApp->getDAppNew()->sendEvent(w->m_pAlbumview, &ed); |
| 610 | // QTest::qWait(200); |
| 611 | //} |
| 612 | |
| 613 | TEST(AlbumView, findPicturePathByPhone_test) |
| 614 | { |
| 615 | TEST_CASE_NAME("findPicturePathByPhone_test") |
| 616 | MainWindow *w = dApp->getMainWindow(); |
| 617 | w->albumBtnClicked(); |
| 618 | QTest::qWait(500); |
| 619 | |
| 620 | QString testPath = testPath_test; |
| 621 | w->m_pAlbumview->findPicturePathByPhone(testPath); |
| 622 | QTest::qWait(500); |
| 623 | } |
| 624 | |
| 625 | TEST(AlbumView, onLeftListDropEvent_test) |
| 626 | { |
| 627 | TEST_CASE_NAME("onLeftListDropEvent_test") |
| 628 | MainWindow *w = dApp->getMainWindow(); |
| 629 | w->albumBtnClicked(); |
| 630 | w->m_pAlbumview->m_pLeftListView->m_pCustomizeListView->setCurrentRow(0); |
| 631 | QModelIndex curIndex = w->m_pAlbumview->m_pLeftListView->m_pCustomizeListView->currentIndex(); |
| 632 | QTest::qWait(500); |
| 633 | w->m_pAlbumview->onLeftListDropEvent(curIndex); |
| 634 | QTest::qWait(500); |
| 635 | } |
| 636 | |
| 637 | TEST(AlbumView, albumView_other1_test) |
| 638 | { |
| 639 | TEST_CASE_NAME("albumView_other1_test") |
| 640 | MainWindow *w = dApp->getMainWindow(); |
| 641 | w->albumBtnClicked(); |
| 642 | |
| 643 | QMimeData mimedata; |
| 644 | QList<QUrl> li; |
| 645 | QString lastImportPath = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first(); |
| 646 | lastImportPath += "/test/4l6r5y.png"; |
| 647 | li.append(QUrl(lastImportPath)); |
| 648 | mimedata.setUrls(li); |
| 649 | |
| 650 | |
| 651 | QPoint pos = QPoint(20, 20); |
| 652 | QDragEnterEvent dee(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 653 | w->m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->dragEnterEvent(&dee); |
| 654 | |
| 655 | QDragMoveEvent dme(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 656 | w->m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->dragMoveEvent(&dme); |
| 657 | |
| 658 | QDropEvent de(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 659 | w->m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->dropEvent(&de); |
| 660 | |
| 661 | w->m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->setViewMode(QListView::IconMode); |
| 662 | w->m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->viewOptions(); |
| 663 | |
| 664 | w->m_pAlbumview->m_currentType = ALBUM_PATHTYPE_BY_PHONE; |
| 665 | w->m_pAlbumview->updateRightView(); |
| 666 | |
| 667 | w->m_pAlbumview->m_currentType = COMMON_STR_FAVORITES; |
| 668 | w->m_pAlbumview->updateRightView(); |
| 669 | |
| 670 | w->m_pAlbumview->updateAlbumView(w->m_pAlbumview->m_currentType); |
| 671 | w->m_pAlbumview->updateRightMyFavoriteView(); |
| 672 | // w->m_pAlbumview->onTrashDeleteBtnClicked(); |
| 673 | |
| 674 | w->m_pAlbumview->dragEnterEvent(&dee); |
| 675 | w->m_pAlbumview->dragMoveEvent(&dme); |
| 676 | |
| 677 | w->m_pAlbumview->onKeyF2(); |
| 678 | |
| 679 | w->m_pAlbumview->SearchReturnUpdate(); |
| 680 | QString str = ""; |
| 681 | w->m_pAlbumview->findPicturePathByPhone(str); |
| 682 | w->m_pAlbumview->importAllBtnClicked(); |
| 683 | w->m_pAlbumview->needUnMount(""); |
| 684 | |
| 685 | w->m_pAlbumview->m_currentType = COMMON_STR_RECENT_IMPORTED; |
| 686 | w->m_pAlbumview->restorePicNum(); |
| 687 | |
| 688 | w->m_pAlbumview->m_currentType = COMMON_STR_FAVORITES; |
| 689 | w->m_pAlbumview->restorePicNum(); |
| 690 | |
| 691 | w->m_pAlbumview->m_currentType = COMMON_STR_CUSTOM; |
| 692 | w->m_pAlbumview->restorePicNum(); |
| 693 | |
| 694 | w->m_pAlbumview->onThemeTypeChanged(DGuiApplicationHelper::DarkType); |
| 695 | w->m_pAlbumview->onThemeTypeChanged(DGuiApplicationHelper::LightType); |
| 696 | |
| 697 | w->m_pAlbumview->onImportFailedToView(); |
| 698 | w->m_pAlbumview->onWaitDailogTimeout(); |
| 699 | |
| 700 | |
| 701 | QTest::qWait(500); |
| 702 | } |
| 703 | |
| 704 | TEST(AlbumViewList, albumViewList_other3_test) |
| 705 | { |
| 706 | TEST_CASE_NAME("albumViewList_other3_test") |
| 707 | |
| 708 | MainWindow *w = dApp->getMainWindow(); |
| 709 | |
| 710 | QEnterEvent ee(QPoint(10, 10), QPoint(10, 10), QPoint(10, 10)); |
| 711 | w->m_pAlbumview->m_pLeftListView->m_pAddListBtn->enterEvent(&ee); |
| 712 | |
| 713 | } |
| 714 | |
| 715 | TEST(AlbumViewList, albumViewList_other4_test) |
| 716 | { |
| 717 | TEST_CASE_NAME("albumViewList_other4_test") |
| 718 | |
| 719 | MainWindow *w = dApp->getMainWindow(); |
| 720 | ThumbnailListView *pThumbnailListView = w->findChild<ThumbnailListView *>(ImportTime_pThumbnailListView); |
| 721 | |
| 722 | if (pThumbnailListView) { |
| 723 | emit pThumbnailListView->openImage(0, pThumbnailListView->getFileList().first(), false); |
| 724 | emit pThumbnailListView->openImage(-1, "", false); |
| 725 | QStringList stringList; |
| 726 | emit pThumbnailListView->sigSelectAll(); |
| 727 | emit pThumbnailListView->sigMouseMove(); |
| 728 | emit pThumbnailListView->sigMouseRelease(); |
| 729 | emit pThumbnailListView->customContextMenuRequested(QPoint()); |
| 730 | } |
| 731 | |
| 732 | DCommandLinkButton *pChose = w->findChild<DCommandLinkButton *>(All_Picture_Thembnail); |
| 733 | |
| 734 | if (pChose) { |
| 735 | emit pChose->clicked(); |
| 736 | } |
| 737 | |
| 738 | ImportTimeLineView *pImpTimeLineWidget = w->findChild<ImportTimeLineView *>(AlbumView_pImpTimeLineWidget); |
| 739 | |
| 740 | if (pImpTimeLineWidget) { |
| 741 | // pImpTimeLineWidget->on_DelLabel(); |
| 742 | |
| 743 | QMimeData mimedata; |
| 744 | QList<QUrl> li; |
| 745 | QString lastImportPath = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first(); |
| 746 | lastImportPath += "/test/4l6r5y.png"; |
| 747 | li.append(QUrl(lastImportPath)); |
| 748 | mimedata.setUrls(li); |
| 749 | |
| 750 | QPoint pos = QPoint(20, 20); |
| 751 | QDragEnterEvent dee(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 752 | pImpTimeLineWidget->dragEnterEvent(&dee); |
| 753 | |
| 754 | QDragMoveEvent dme(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 755 | pImpTimeLineWidget->dragMoveEvent(&dme); |
| 756 | |
| 757 | QDropEvent de(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 758 | pImpTimeLineWidget->dropEvent(&de); |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | TEST(AlbumViewList, albumViewList_other5_test) |
| 763 | { |
| 764 | TEST_CASE_NAME("albumViewList_other5_test") |
| 765 | |
| 766 | MainWindow *w = dApp->getMainWindow(); |
| 767 | |
| 768 | QMimeData mimedata; |
| 769 | QList<QUrl> li; |
| 770 | QString lastImportPath = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first(); |
| 771 | lastImportPath += "/test/4l6r5y.png"; |
| 772 | li.append(QUrl(lastImportPath)); |
| 773 | mimedata.setUrls(li); |
| 774 | |
| 775 | QPoint pos = QPoint(20, 20); |
| 776 | QDragEnterEvent dee(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 777 | w->m_pAlbumview->m_pImportView->dragEnterEvent(&dee); |
| 778 | |
| 779 | QDragMoveEvent dme(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 780 | w->m_pAlbumview->m_pImportView->dragMoveEvent(&dme); |
| 781 | |
| 782 | QDropEvent de(pos, Qt::IgnoreAction, &mimedata, Qt::LeftButton, Qt::NoModifier); |
| 783 | w->m_pAlbumview->m_pImportView->dropEvent(&de); |
| 784 | |
| 785 | w->m_pAlbumview->m_pImportView->imageImported(true); |
| 786 | w->m_pAlbumview->m_pImportView->imageImported(false); |
| 787 | |
| 788 | |
| 789 | MainWidget *mainWidget = w->m_commandLine->findChild<MainWidget *>("MainWidget"); |
| 790 | |
| 791 | // if (mainWidget) { |
| 792 | // NavigationWidget *nw = mainWidget->m_viewPanel->m_nav.widget(); |
| 793 | // nw->setAlwaysHidden(false); |
| 794 | // nw->setAlwaysHidden(true); |
| 795 | // nw->transImagePos(QPoint(0, 0)); |
| 796 | |
| 797 | // mainWidget->m_viewPanel->m_ttbc->deleteImage(); |
| 798 | // } |
| 799 | } |
| 800 | |
| 801 | TEST(AlbumViewList, albumViewList_other6_test) |
| 802 | { |
| 803 | TEST_CASE_NAME("albumViewList_other6_test") |
| 804 | |
| 805 | GraphicsMovieItem gmi_1(testPath_Pictures + "/2e5y8y.jpg", ""); |
| 806 | GraphicsMovieItem gmi_2("", ""); |
| 807 | |
| 808 | ImageView *iv = new ImageView; |
| 809 | iv->setImage(""); |
| 810 | iv->setImage(testPath_Pictures + "/2e5y8y.jpg"); |
| 811 | iv->windowRelativeScale(); |
| 812 | iv->imageRelativeScale(); |
| 813 | iv->isWholeImageVisible(); |
| 814 | iv->onThemeTypeChanged(); |
| 815 | |
| 816 | ImgInfoDialog iid(""); |
| 817 | iid.height(); |
| 818 | } |
| 819 | |
| 820 | TEST(AlbumViewList, deviceMount) |
| 821 | { |
| 822 | TEST_CASE_NAME("deviceMount") |
| 823 | //TEST_CASE_NAME("load") |
| 824 | |
| 825 | auto w = dApp->getMainWindow(); |
| 826 | |
| 827 | #ifdef SELECT_CASE |
| 828 | w->m_pAlbumview = new AlbumView; |
| 829 | #endif |
| 830 | |
| 831 | w->albumBtnClicked(); |
| 832 | |
| 833 | //挂载点位置 |
| 834 | QString mountPath = QString("%1/Pictures/%2/") |
| 835 | .arg(QDir::homePath()) |
| 836 | .arg("album_ut_mount_point"); |
| 837 | |
| 838 | //初始化设备挂载mock |
| 839 | Mock_Mount mockMount(mountPath); |
| 840 | |
| 841 | //执行挂载 |
| 842 | QExplicitlySharedDataPointer<DGioMount> mount(nullptr); |
| 843 | w->m_pAlbumview->onVfsMountChangedAdd(mount); |
| 844 | |
| 845 | //等待加载完成 |
| 846 | QTest::qWait(2000); |
| 847 | |
| 848 | //刷新视图 |
| 849 | w->m_pAlbumview->updateRightMountView(); |
| 850 | |
| 851 | //将mock环境设置为卸载设备 |
| 852 | mockMount.setToUmountDevice(); |
| 853 | |
| 854 | //卸载设备 |
| 855 | w->m_pAlbumview->onUnMountSignal(mountPath + "DCIM/"); |
| 856 | |
| 857 | QTest::qWait(2000); |
| 858 | } |
| 859 | |
| 860 | extern QString formatSize(qint64 num, bool withUnitVisible = true, int precision = 1, int forceUnit = -1, QStringList unitList = QStringList()); |
| 861 | TEST(Albumview, formatSize) |
| 862 | { |
| 863 | TEST_CASE_NAME("formatSize") |
| 864 | |
| 865 | formatSize(1ll); //B |
| 866 | formatSize(2ll * 1024); //KB |
| 867 | formatSize(3ll * 1024 * 1024); //MB |
| 868 | formatSize(4ll * 1024 * 1024 * 1024); //GB |
| 869 | formatSize(5ll * 1024 * 1024 * 1024 * 1024); //TB |
| 870 | formatSize(5ll * 1024 * 1024 * 1024 * 1024 * 1024); //EB |
| 871 | formatSize(0ll); //0 |
| 872 | formatSize(-1ll); //error |
| 873 | } |