Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: common/test/RegistryTest.cpp

Issue 6216090891845632: Issue #404 - Create common library shared between plugin/engine and installer (Closed)
Patch Set: final check after rebase Created May 19, 2015, 3:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « common/test/IeVersionTest.cpp ('k') | src/engine/Main.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <gtest/gtest.h> 18 #include <gtest/gtest.h>
19 19 #include "Registry.h"
20 #include "../src/shared/Registry.h"
21 #include "../src/shared/IE_Version.h"
22 20
23 using namespace AdblockPlus; 21 using namespace AdblockPlus;
24 22
25 //---------------------------------- 23 TEST(RegistryTest, Simple00)
26 // Registry_Key
27 //----------------------------------
28 TEST(RegistryTest, simple_0)
29 { 24 {
30 ASSERT_NO_THROW({ auto r = RegistryKey(HKEY_CLASSES_ROOT, L"CLSID"); }); 25 ASSERT_NO_THROW({ auto r = RegistryKey(HKEY_CLASSES_ROOT, L"CLSID"); });
31 } 26 }
32 27
33 TEST(RegistryTest, constructor_illegal_argument_0) 28 TEST(RegistryTest, Simple01)
34 { 29 {
35 ASSERT_ANY_THROW({ auto r1 = RegistryKey(HKEY_CLASSES_ROOT, L""); }); 30 ASSERT_ANY_THROW({ auto r = RegistryKey(HKEY_CLASSES_ROOT, L"IREALLYHOPENOBODY HASREGISTEREDTHISKEY"); });
36 } 31 }
37 32
38 TEST(RegistryTest, value_notfound_0) 33 TEST(RegistryTest, ConstructorIllegalArgument00)
39 { 34 {
40 auto r1 = RegistryKey(HKEY_CLASSES_ROOT, L"CLSID"); 35 // Empty string arguments are illegal by fiat; there's an explicit check
41 ASSERT_ANY_THROW({ r1.value_wstring(L"nonexistent"); }); 36 ASSERT_ANY_THROW({ auto r = RegistryKey(HKEY_CLASSES_ROOT, L""); });
42 } 37 }
43 38
44 //---------------------------------- 39 TEST(RegistryTest, ValueNotFound00)
45 // IE_Version
46 //----------------------------------
47 /*
48 * Exact version tests enabled by default.
49 * If they are disabled, gtext will report 2 disabled tests.
50 */
51 #if !defined(DISABLE_EXACT_TESTS)
52 #define exact(x) exact_##x
53 #else
54 #define exact(x) DISABLED_exact_##x
55 #endif
56 /*
57 * Define a default version as the current version of IE in general release.
58 * Predefine on the command line to compile tests for non-standard development e nvironments.
59 */
60 #ifndef INSTALLED_IE_VERSION
61 #define INSTALLED_IE_VERSION 11
62 #endif
63
64 TEST(IE_Version_Test, sanity_string)
65 { 40 {
66 std::wstring version = AdblockPlus::IE::InstalledVersionString(); 41 auto r = RegistryKey(HKEY_CLASSES_ROOT, L"CLSID");
67 ASSERT_FALSE(version.length() == 0); // separate test for default value 42 ASSERT_ANY_THROW({ r.value_wstring(L"nonexistent"); });
68 ASSERT_TRUE(version.length() >= 2);
69 } 43 }
70
71 TEST(IE_Version_Test, sanity_major)
72 {
73 int version = AdblockPlus::IE::InstalledMajorVersion();
74 ASSERT_NE(version, 0); // separate test for default value
75 ASSERT_GE(version, 6);
76 ASSERT_LE(version, 12);
77 EXPECT_NE(version, 12); // This check will point out when the test needs updat ing.
78 }
79
80 TEST(IE_Version_Test, exact(string))
81 {
82 std::wstring version = AdblockPlus::IE::InstalledVersionString();
83 std::wstring expected = std::to_wstring(INSTALLED_IE_VERSION) + L".";
84 ASSERT_EQ(expected, version.substr(0, expected.length()));
85 }
86
87 TEST(IE_Version_Test, exact(major))
88 {
89 int version = AdblockPlus::IE::InstalledMajorVersion();
90 ASSERT_EQ(version, INSTALLED_IE_VERSION);
91 }
OLDNEW
« no previous file with comments | « common/test/IeVersionTest.cpp ('k') | src/engine/Main.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld