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

Delta Between Two Patch Sets: test/RegistryTest.cpp

Issue 5171515343503360: Issue #41 - Bring method of determining IE version up to date (Closed)
Left Patch Set: simplify Registry_Key Created July 26, 2014, 5 p.m.
Right Patch Set: Final (?) 2 Created Jan. 5, 2015, 1:02 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« src/plugin/PluginWbPassThrough.cpp ('K') | « src/shared/Registry.cpp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2014 Eyeo GmbH 3 * Copyright (C) 2014 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
20 #include "../src/shared/Registry.h" 20 #include "../src/shared/Registry.h"
21 #include "../src/shared/IE_Version.h" 21 #include "../src/shared/IE_Version.h"
22 22
23 using namespace AdblockPlus; 23 using namespace AdblockPlus;
24 24
25 //---------------------------------- 25 //----------------------------------
26 // Registry_Key 26 // Registry_Key
27 //---------------------------------- 27 //----------------------------------
28 28 TEST(RegistryTest, simple_0)
29 class Registry_Test
sergei 2014/07/28 11:46:27 It's not needed, remove it.
Eric 2014/07/29 12:42:25 Explicit class declarations are required for comma
sergei 2014/07/29 14:45:56 This class is even not used, because tests are not
Eric 2014/07/29 15:17:22 Go read the documentation about how --gtest_filter
sergei 2014/07/30 10:42:04 I've checked the documentation and tried it and it
Eric 2014/07/30 13:02:04 OK. Tested on my end. Where in the googletest doc
30 : public ::testing::Test
31 { 29 {
32 }; 30 ASSERT_NO_THROW({ auto r = RegistryKey(HKEY_CLASSES_ROOT, L"CLSID"); });
33
34 TEST(Registry_Test, simple_0)
sergei 2014/07/28 11:46:27 What does `simple_0` mean? Call it like `RegistryK
35 {
36 ASSERT_NO_THROW({ auto r = Registry_Key(HKEY_CLASSES_ROOT, L"CLSID"); });
37 } 31 }
38 32
39 TEST(Registry_Test, constructor_illegal_argument_0) 33 TEST(RegistryTest, constructor_illegal_argument_0)
sergei 2014/07/28 11:46:27 `ctr_should_throw_exception_if_key_is_empty`
40 { 34 {
41 ASSERT_ANY_THROW({ auto r1 = Registry_Key(HKEY_CLASSES_ROOT, L""); }); 35 ASSERT_ANY_THROW({ auto r1 = RegistryKey(HKEY_CLASSES_ROOT, L""); });
42 } 36 }
43 37
44 TEST(Registry_Test, value_notfound_0) 38 TEST(RegistryTest, value_notfound_0)
sergei 2014/07/28 11:46:27 StringValue_should_throw_if_value_not_found
45 { 39 {
46 auto r1 = Registry_Key(HKEY_CLASSES_ROOT, L"CLSID"); 40 auto r1 = RegistryKey(HKEY_CLASSES_ROOT, L"CLSID");
47 ASSERT_ANY_THROW({ r1.value_wstring(L"nonexistent"); }); 41 ASSERT_ANY_THROW({ r1.value_wstring(L"nonexistent"); });
48 } 42 }
49 43
50 //---------------------------------- 44 //----------------------------------
sergei 2014/07/28 11:46:27 Move it into another cpp file
Eric 2014/07/29 12:42:25 At least for now, that's overkill.
sergei 2014/07/29 14:45:56 It's not an overkill - it will be difficult to loc
51 // IE_Version 45 // IE_Version
sergei 2015/01/06 13:39:11 The tests below should be in IE_versionTest.cpp
Eric 2015/01/06 17:10:34 OK. I'll do it in a later change. We need to move
52 //---------------------------------- 46 //----------------------------------
53 47 /*
54 class IE_Version_Test 48 * Exact version tests enabled by default.
sergei 2014/07/28 11:46:27 It's not needed
55 : public ::testing::Test 49 * If they are disabled, gtext will report 2 disabled tests.
56 { 50 */
57 }; 51 #if !defined(DISABLE_EXACT_TESTS)
58 52 #define exact(x) exact_##x
sergei 2015/01/06 13:39:11 What is the aim of it? I would remove it.
Eric 2015/01/06 17:10:34 Ordinarily unit tests should always run independen
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 */
59 #ifndef INSTALLED_IE_VERSION 60 #ifndef INSTALLED_IE_VERSION
60 #define INSTALLED_IE_VERSION 11 61 #define INSTALLED_IE_VERSION 11
61 #endif 62 #endif
62 63
63 #if INSTALLED_IE_VERSION == 11
64 #define perform_version_test true
65 #define expected_version_string L"11."
sergei 2014/07/28 11:46:27 Why do we need the point at the end?
Eric 2014/07/29 12:42:25 It's the last character of the longest initial sub
sergei 2014/07/29 14:45:56 Still I have not get your point. "11" or "10" or "
66 #else
67 #define perform_version_test false
68 #endif
69
70 TEST(IE_Version_Test, sanity_string) 64 TEST(IE_Version_Test, sanity_string)
71 { 65 {
72 std::wstring version = AdblockPlus::IE::installed_version_string(); 66 std::wstring version = AdblockPlus::IE::InstalledVersionString();
73 ASSERT_NE(version, L""); 67 ASSERT_FALSE(version.length() == 0); // separate test for default value
74 // Replace with local version prefix as appropriate 68 ASSERT_TRUE(version.length() >= 2);
75 if (perform_version_test)
76 {
77 ASSERT_EQ(0, version.compare(0, 3, expected_version_string));
78 }
79 } 69 }
80 70
81 TEST(IE_Version_Test, sanity_major) 71 TEST(IE_Version_Test, sanity_major)
82 { 72 {
83 int version = AdblockPlus::IE::installed_major_version(); 73 int version = AdblockPlus::IE::InstalledMajorVersion();
84 ASSERT_NE(version, 0); 74 ASSERT_NE(version, 0); // separate test for default value
85 // Replace with local major version 75 ASSERT_GE(version, 6);
86 if (perform_version_test) 76 ASSERT_LE(version, 12);
87 { 77 EXPECT_NE(version, 12); // This check will point out when the test needs updat ing.
88 ASSERT_EQ(version, INSTALLED_IE_VERSION);
Oleksandr 2014/07/27 22:13:30 What if we just tested here for a range of values
sergei 2014/07/28 11:46:27 Agree about the range, get rid of the hacks `perfo
Eric 2014/07/28 11:48:43 The problem is that we shouldn't make many assumpt
sergei 2014/07/29 14:45:56 What does this test tests? `sanity_major` says not
89 }
90 } 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 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld