summaryrefslogtreecommitdiffstats
path: root/mmc_updater/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'mmc_updater/src/tests')
-rw-r--r--mmc_updater/src/tests/CMakeLists.txt47
-rw-r--r--mmc_updater/src/tests/TestFileUtils.cpp79
-rw-r--r--mmc_updater/src/tests/TestFileUtils.h10
-rw-r--r--mmc_updater/src/tests/TestParseScript.cpp24
-rw-r--r--mmc_updater/src/tests/TestParseScript.h8
-rw-r--r--mmc_updater/src/tests/TestUtils.h108
-rw-r--r--mmc_updater/src/tests/file_list.xml37
-rw-r--r--mmc_updater/src/tests/new_app.cpp8
-rw-r--r--mmc_updater/src/tests/old_app.cpp7
-rw-r--r--mmc_updater/src/tests/test.manifest27
-rw-r--r--mmc_updater/src/tests/test.rc28
11 files changed, 0 insertions, 383 deletions
diff --git a/mmc_updater/src/tests/CMakeLists.txt b/mmc_updater/src/tests/CMakeLists.txt
deleted file mode 100644
index 5a96d7c9..00000000
--- a/mmc_updater/src/tests/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..")
-
-if(APPLE)
- set(HELPER_SHARED_SOURCES ../StlSymbolsLeopard.cpp)
-endif()
-
-# # Create helper binaries for unit tests
-# add_executable(oldapp
-# old_app.cpp
-# ${HELPER_SHARED_SOURCES}
-# )
-# add_executable(newapp
-# new_app.cpp
-# ${HELPER_SHARED_SOURCES}
-# )
-
-# Install data files required by unit tests
-set(TEST_FILES
- file_list.xml
-)
-
-foreach(TEST_FILE ${TEST_FILES})
- execute_process(
- COMMAND
- "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE}" "${CMAKE_CURRENT_BINARY_DIR}"
- )
-endforeach()
-
-# Add unit test binaries
-macro(ADD_UPDATER_TEST CLASS)
- set(TEST_TARGET updater_${CLASS})
- unset(srcs)
- list(APPEND srcs ${CLASS}.cpp)
- if(WIN32)
- list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc)
- endif()
- add_executable(${TEST_TARGET} ${srcs})
- target_link_libraries(${TEST_TARGET} updatershared)
- add_test(NAME ${TEST_TARGET} COMMAND ${TEST_TARGET})
- if(APPLE)
- set_target_properties(${TEST_TARGET} PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa")
- endif()
-endmacro()
-
-add_updater_test(TestParseScript)
-add_updater_test(TestFileUtils)
diff --git a/mmc_updater/src/tests/TestFileUtils.cpp b/mmc_updater/src/tests/TestFileUtils.cpp
deleted file mode 100644
index f8535a28..00000000
--- a/mmc_updater/src/tests/TestFileUtils.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "TestFileUtils.h"
-
-#include "FileUtils.h"
-#include "TestUtils.h"
-
-void TestFileUtils::testDirName()
-{
- std::string dirName;
- std::string fileName;
-
-#ifdef PLATFORM_WINDOWS
- // absolute paths
- dirName = FileUtils::dirname("E:/Some Dir/App.exe");
- TEST_COMPARE(dirName,"E:/Some Dir");
- fileName = FileUtils::fileName("E:/Some Dir/App.exe");
- TEST_COMPARE(fileName,"App.exe");
-
- dirName = FileUtils::dirname("C:/Users/kitteh/AppData/Local/Temp/MultiMC5-yidaaa/MultiMC.exe");
- TEST_COMPARE(dirName,"C:/Users/kitteh/AppData/Local/Temp/MultiMC5-yidaaa");
- fileName = FileUtils::fileName("C:/Users/kitteh/AppData/Local/Temp/MultiMC5-yidaaa/MultiMC.exe");
- TEST_COMPARE(fileName,"MultiMC.exe");
-
-#else
- // absolute paths
- dirName = FileUtils::dirname("/home/tester/foo bar/baz");
- TEST_COMPARE(dirName,"/home/tester/foo bar");
- fileName = FileUtils::fileName("/home/tester/foo bar/baz");
- TEST_COMPARE(fileName,"baz");
-#endif
- // current directory
- dirName = FileUtils::dirname("App.exe");
- TEST_COMPARE(dirName,".");
- fileName = FileUtils::fileName("App.exe");
- TEST_COMPARE(fileName,"App.exe");
-
- // relative paths
- dirName = FileUtils::dirname("Foo/App.exe");
- TEST_COMPARE(dirName,"Foo");
- fileName = FileUtils::fileName("Foo/App.exe");
- TEST_COMPARE(fileName,"App.exe");
-}
-
-void TestFileUtils::testIsRelative()
-{
-#ifdef PLATFORM_WINDOWS
- TEST_COMPARE(FileUtils::isRelative("temp"),true);
- TEST_COMPARE(FileUtils::isRelative("D:/temp"),false);
- TEST_COMPARE(FileUtils::isRelative("d:/temp"),false);
-#else
- TEST_COMPARE(FileUtils::isRelative("/tmp"),false);
- TEST_COMPARE(FileUtils::isRelative("tmp"),true);
-#endif
-}
-
-void TestFileUtils::testSymlinkFileExists()
-{
-#ifdef PLATFORM_UNIX
- const char* linkName = "link-name";
- FileUtils::removeFile(linkName);
- FileUtils::createSymLink(linkName, "target-that-does-not-exist");
- TEST_COMPARE(FileUtils::fileExists(linkName), true);
-#endif
-}
-
-void TestFileUtils::testStandardDirs()
-{
- std::string tmpDir = FileUtils::tempPath();
- TEST_COMPARE(FileUtils::fileExists(tmpDir.data()), true);
-}
-
-int main(int,char**)
-{
- TestList<TestFileUtils> tests;
- tests.addTest(&TestFileUtils::testDirName);
- tests.addTest(&TestFileUtils::testIsRelative);
- tests.addTest(&TestFileUtils::testSymlinkFileExists);
- tests.addTest(&TestFileUtils::testStandardDirs);
- return TestUtils::runTest(tests);
-}
diff --git a/mmc_updater/src/tests/TestFileUtils.h b/mmc_updater/src/tests/TestFileUtils.h
deleted file mode 100644
index 1a45164b..00000000
--- a/mmc_updater/src/tests/TestFileUtils.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#pragma once
-
-class TestFileUtils
-{
- public:
- void testDirName();
- void testIsRelative();
- void testSymlinkFileExists();
- void testStandardDirs();
-};
diff --git a/mmc_updater/src/tests/TestParseScript.cpp b/mmc_updater/src/tests/TestParseScript.cpp
deleted file mode 100644
index f4453957..00000000
--- a/mmc_updater/src/tests/TestParseScript.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "TestParseScript.h"
-
-#include "TestUtils.h"
-#include "UpdateScript.h"
-
-#include <iostream>
-#include <algorithm>
-
-void TestParseScript::testParse()
-{
- UpdateScript script;
-
- script.parse("file_list.xml");
-
- TEST_COMPARE(script.isValid(),true);
-}
-
-int main(int,char**)
-{
- TestList<TestParseScript> tests;
- tests.addTest(&TestParseScript::testParse);
- return TestUtils::runTest(tests);
-}
-
diff --git a/mmc_updater/src/tests/TestParseScript.h b/mmc_updater/src/tests/TestParseScript.h
deleted file mode 100644
index 528e97a8..00000000
--- a/mmc_updater/src/tests/TestParseScript.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#pragma once
-
-class TestParseScript
-{
- public:
- void testParse();
-};
-
diff --git a/mmc_updater/src/tests/TestUtils.h b/mmc_updater/src/tests/TestUtils.h
deleted file mode 100644
index 68d97da5..00000000
--- a/mmc_updater/src/tests/TestUtils.h
+++ /dev/null
@@ -1,108 +0,0 @@
-#pragma once
-
-#include <iostream>
-#include <functional>
-#include <string>
-#include <vector>
-
-template <class T>
-class TestList
-{
- public:
- void addTest(void (T::*test)())
- {
- m_tests.push_back(std::mem_fun(test));
- }
-
- int size() const
- {
- return m_tests.size();
- }
-
- void runTest(T* testInstance, int i)
- {
- m_tests.at(i)(testInstance);
- }
-
- private:
- std::vector<std::mem_fun_t<void,T> > m_tests;
-};
-
-class TestUtils
-{
- public:
- template <class X, class Y>
- static void compare(const X& x, const Y& y, const char* xString, const char* yString)
- {
- if (x != y)
- {
- throw "Actual and expected values differ. "
- "Actual: " + toString(x,xString) +
- " Expected: " + toString(y,yString);
- }
- }
-
- template <typename T>
- static std::string toString(T value, const char* context)
- {
- return "Unprintable: " + std::string(context);
- }
-
- template <class T>
- static int runTest(class TestList<T>& tests) throw ()
- {
- std::string errorText;
- try
- {
- T testInstance;
- for (int i=0; i < tests.size(); i++)
- {
- tests.runTest(&testInstance,i);
- }
- }
- catch (const std::exception& ex)
- {
- errorText = ex.what();
- }
- catch (const std::string& error)
- {
- errorText = error;
- }
- catch (...)
- {
- errorText = "Unknown exception";
- }
-
- if (errorText.empty())
- {
- std::cout << "Test passed" << std::endl;
- return 0;
- }
- else
- {
- std::cout << "Test failed: " << errorText << std::endl;
- return 1;
- }
- }
-};
-
-template <>
-inline std::string TestUtils::toString(const std::string& value, const char*)
-{
- return value;
-}
-template <>
-inline std::string TestUtils::toString(std::string value, const char*)
-{
- return value;
-}
-template <>
-inline std::string TestUtils::toString(const char* value, const char*)
-{
- return value;
-}
-
-#define TEST_COMPARE(x,y) \
- TestUtils::compare(x,y,#x,#y);
-
-
diff --git a/mmc_updater/src/tests/file_list.xml b/mmc_updater/src/tests/file_list.xml
deleted file mode 100644
index 06ba501d..00000000
--- a/mmc_updater/src/tests/file_list.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0"?>
-<update version="3">
- <install>
- <file>
- <name>$APP_FILENAME</name>
- <hash>$UPDATED_APP_HASH</hash>
- <size>$UPDATED_APP_SIZE</size>
- <permissions>0755</permissions>
- <package>app-pkg</package>
- <is-main-binary>true</is-main-binary>
- </file>
- <file>
- <name>$UPDATER_FILENAME</name>
- <hash>$UPDATER_HASH</hash>
- <size>$UPDATER_SIZE</size>
- <permissions>0755</permissions>
- </file>
- <!-- Test symlink !-->
- <file>
- <name>test-dir/app-symlink</name>
- <target>../app</target>
- </file>
- <!-- Test file in new directory !-->
- <file>
- <name>new-dir/new-dir2/new-file.txt</name>
- <hash>$TEST_FILENAME</hash>
- <size>$TEST_SIZE</size>
- <package>app-pkg</package>
- <permissions>0644</permissions>
- </file>
- </install>
- <uninstall>
- <!-- TODO - List some files to uninstall here !-->
- <file>file-to-uninstall.txt</file>
- <file>symlink-to-file-to-uninstall.txt</file>
- </uninstall>
-</update>
diff --git a/mmc_updater/src/tests/new_app.cpp b/mmc_updater/src/tests/new_app.cpp
deleted file mode 100644
index 7fad1380..00000000
--- a/mmc_updater/src/tests/new_app.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <iostream>
-
-int main(int,char**)
-{
- std::cout << "new app starting" << std::endl;
- return 0;
-}
-
diff --git a/mmc_updater/src/tests/old_app.cpp b/mmc_updater/src/tests/old_app.cpp
deleted file mode 100644
index 476a3405..00000000
--- a/mmc_updater/src/tests/old_app.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <iostream>
-
-int main(int,char**)
-{
- std::cout << "old app starting" << std::endl;
- return 0;
-}
diff --git a/mmc_updater/src/tests/test.manifest b/mmc_updater/src/tests/test.manifest
deleted file mode 100644
index 8b4dbb98..00000000
--- a/mmc_updater/src/tests/test.manifest
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
- <assemblyIdentity name="MultiMC.Test.0" type="win32" version="5.0.0.0" />
- <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
- <security>
- <requestedPrivileges>
- <requestedExecutionLevel level="asInvoker" uiAccess="false"/>
- </requestedPrivileges>
- </security>
- </trustInfo>
- <dependency>
- <dependentAssembly>
- <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"/>
- </dependentAssembly>
- </dependency>
- <description>Custom Minecraft launcher for managing multiple installs.</description>
- <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
- <application>
- <!--The ID below indicates app support for Windows Vista -->
- <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
- <!--The ID below indicates app support for Windows 7 -->
- <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
- <!--The ID below indicates app support for Windows Developer Preview / Windows 8 -->
- <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
- </application>
- </compatibility>
-</assembly> \ No newline at end of file
diff --git a/mmc_updater/src/tests/test.rc b/mmc_updater/src/tests/test.rc
deleted file mode 100644
index a288dba6..00000000
--- a/mmc_updater/src/tests/test.rc
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-
-1 RT_MANIFEST "test.manifest"
-
-VS_VERSION_INFO VERSIONINFO
-FILEVERSION 1,0,0,0
-FILEOS VOS_NT_WINDOWS32
-FILETYPE VFT_APP
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "000004b0"
- BEGIN
- VALUE "CompanyName", "MultiMC Contributors"
- VALUE "FileDescription", "Testcase"
- VALUE "FileVersion", "1.0.0.0"
- VALUE "ProductName", "MultiMC Testcase"
- VALUE "ProductVersion", "5"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x0000, 0x04b0 // Unicode
- END
-END