File indexing completed on 2024-04-28 16:08:41

0001 /***************************************************************************
0002  *   Copyright (C) 2017 by Linuxstopmotion contributors;                   *
0003  *   see the AUTHORS file for details.                                     *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 
0021 #include "oomtestutil.h"
0022 #include "testhome.h"
0023 #include "fakefiles.h"
0024 #include "src/domain/animation/workspacefile.h"
0025 #include "src/foundation/uiexception.h"
0026 
0027 #include <QtTest/QtTest>
0028 
0029 #include "tworkspace.h"
0030 
0031 TestWorkspace::TestWorkspace() : testEnvFs(0), mfs(0) {
0032     testEnvFs = new TestHome();
0033     mfs = new RealOggEmptyJpg();
0034 }
0035 
0036 TestWorkspace::~TestWorkspace() {
0037     delete mfs;
0038     delete testEnvFs;
0039 }
0040 
0041 void TestWorkspace::jpgsCanBeCopiedIntoWorkspace() {
0042     wrapFileSystem(0);
0043     wrapFileSystem(testEnvFs);
0044     wrapFileSystem(mfs);
0045     try {
0046         TemporaryWorkspaceFile wf("/tmp/image.jpg",
0047                 WorkspaceFileType::image());
0048     } catch (...) {
0049         QFAIL("Copying .jpg image to workspace should be OK");
0050     }
0051     try {
0052         TemporaryWorkspaceFile wf("/tmp/image.jpeg",
0053                 WorkspaceFileType::image());
0054     } catch (...) {
0055         QFAIL("Copying .jpeg image to workspace should be OK");
0056     }
0057     try {
0058         TemporaryWorkspaceFile wf("/tmp/image.JPG",
0059                 WorkspaceFileType::image());
0060     } catch (...) {
0061         QFAIL("Copying .JPG image to workspace should be OK");
0062     }
0063     wrapFileSystem(0);
0064 }
0065 
0066 void TestWorkspace::nonJpgImagesCannotBeCopied() {
0067     wrapFileSystem(0);
0068     wrapFileSystem(testEnvFs);
0069     wrapFileSystem(mfs);
0070     try {
0071         TemporaryWorkspaceFile wf("/tmp/image.png",
0072                 WorkspaceFileType::image());
0073     } catch (UiException& e) {
0074         QCOMPARE(e.warning(), UiException::unsupportedImageType);
0075         wrapFileSystem(0);
0076         return;
0077     } catch (...) {
0078     }
0079     QFAIL("Copying .PNG image to workspace should not be OK");
0080     wrapFileSystem(0);
0081 }