forked from rainmeter/rainmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSkinRegistry_Test.cpp
95 lines (77 loc) · 3.14 KB
/
SkinRegistry_Test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* Copyright (C) 2013 Rainmeter Project Developers
*
* This Source Code Form is subject to the terms of the GNU General Public
* License; either version 2 of the License, or (at your option) any later
* version. If a copy of the GPL was not distributed with this file, You can
* obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */
#include "StdAfx.h"
#include "SkinRegistry.h"
#include "../Common/UnitTest.h"
TEST_CLASS(Library_SkinRegistry_Test)
{
public:
Library_SkinRegistry_Test()
{
std::vector<std::wstring> favorites;
m_SkinRegistry.Populate(L"..\\..\\..\\Library\\Test\\SkinRegistry\\", favorites);
}
TEST_METHOD(TestContents)
{
std::vector<SkinRegistry::File> files1;
files1.emplace_back(L"1.ini");
files1.emplace_back(L"1.ini");
std::vector<SkinRegistry::File> files3;
files3.emplace_back(L"1.ini");
files3.emplace_back(L"2.ini");
files3.emplace_back(L"3.ini");
Assert::AreEqual(5, m_SkinRegistry.GetFolderCount());
const auto& folderA1 = m_SkinRegistry.GetFolder(0);
Assert::AreEqual(L"A1", folderA1.name.c_str());
Assert::AreEqual((int16_t)1, folderA1.level);
Assert::IsTrue(folderA1.files.empty());
const auto& folderA1_B1 = m_SkinRegistry.GetFolder(1);
Assert::AreEqual(L"B1", folderA1_B1.name.c_str());
Assert::AreEqual((int16_t)2, folderA1_B1.level);
Assert::IsTrue(files1 == folderA1_B1.files);
const auto& folderA1_B2 = m_SkinRegistry.GetFolder(2);
Assert::AreEqual(L"B2", folderA1_B2.name.c_str());
Assert::AreEqual((int16_t)2, folderA1_B2.level);
Assert::IsTrue(files1 == folderA1_B2.files);
const auto& folderA1_B2_C1 = m_SkinRegistry.GetFolder(3);
Assert::AreEqual(L"C1", folderA1_B2_C1.name.c_str());
Assert::AreEqual((int16_t)3, folderA1_B2_C1.level);
Assert::IsTrue(files1 == folderA1_B2_C1.files);
const auto& folderA2 = m_SkinRegistry.GetFolder(4);
Assert::AreEqual(L"A2", folderA2.name.c_str());
Assert::AreEqual((int16_t)1, folderA2.level);
Assert::IsTrue(files3 == folderA2.files);
}
TEST_METHOD(TestFindFolderIndex)
{
Assert::AreEqual(3, m_SkinRegistry.FindFolderIndex(L"A1\\B2\\C1"));
Assert::AreEqual(-1, m_SkinRegistry.FindFolderIndex(L"A1\\B5\\C1"));
}
TEST_METHOD(TestFindIndexes)
{
const auto indexes1 = m_SkinRegistry.FindIndexes(L"A1\\B2", L"1.ini");
Assert::IsTrue(indexes1.folder == 2 && indexes1.file == 0);
const auto indexes2 = m_SkinRegistry.FindIndexes(L"A2", L"2.ini");
Assert::IsTrue(indexes2.folder == 4 && indexes2.file == 1);
const auto indexes3 = m_SkinRegistry.FindIndexes(L"A3", L"1.ini");
Assert::IsFalse(indexes3.IsValid());
}
TEST_METHOD(TestFindIndexesForID)
{
const auto indexes1 = m_SkinRegistry.FindIndexesForID(30002);
Assert::IsTrue(indexes1.folder == 2 && indexes1.file == 0);
const auto indexes2 = m_SkinRegistry.FindIndexesForID(30005);
Assert::IsTrue(indexes2.folder == 4 && indexes2.file == 1);
}
TEST_METHOD(TestGetFolderPath)
{
Assert::AreEqual(L"A1\\B2\\C1", m_SkinRegistry.GetFolderPath(3).c_str());
Assert::AreEqual(L"A2", m_SkinRegistry.GetFolderPath(4).c_str());
}
private:
SkinRegistry m_SkinRegistry;
};