| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 /* | 
|  | 2  * This file is part of Adblock Plus <http://adblockplus.org/>, | 
|  | 3  * Copyright (C) 2014 Eyeo GmbH | 
|  | 4  * | 
|  | 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 | 
|  | 7  * published by the Free Software Foundation. | 
|  | 8  * | 
|  | 9  * Adblock Plus is distributed in the hope that it will be useful, | 
|  | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 12  * GNU General Public License for more details. | 
|  | 13  * | 
|  | 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/>. | 
|  | 16  */ | 
|  | 17 | 
|  | 18 #include <gtest/gtest.h> | 
|  | 19 | 
|  | 20 #include "../src/shared/Registry.h" | 
|  | 21 #include "../src/shared/IE_Version.h" | 
|  | 22 | 
|  | 23 using namespace AdblockPlus; | 
|  | 24 | 
|  | 25 //---------------------------------- | 
|  | 26 // Registry_Key | 
|  | 27 //---------------------------------- | 
|  | 28 | 
|  | 29 class Registry_Test | 
|  | 30   : public ::testing::Test | 
|  | 31 { | 
|  | 32 }; | 
|  | 33 | 
|  | 34 TEST(Registry_Test, simple_0) | 
|  | 35 { | 
|  | 36   ASSERT_NO_THROW({ auto r = Registry_Key(HKEY_CLASSES_ROOT, L"CLSID"); }); | 
|  | 37 } | 
|  | 38 | 
|  | 39 TEST(Registry_Test, constructor_illegal_argument_0) | 
|  | 40 { | 
|  | 41   ASSERT_ANY_THROW({ auto r1 = Registry_Key(HKEY_CLASSES_ROOT, L""); }); | 
|  | 42 } | 
|  | 43 | 
|  | 44 TEST(Registry_Test, value_notfound_0) | 
|  | 45 { | 
|  | 46   auto r1 = Registry_Key(HKEY_CLASSES_ROOT, L"CLSID"); | 
|  | 47   ASSERT_ANY_THROW({ r1.value_wstring(L"nonexistent"); }); | 
|  | 48 } | 
|  | 49 | 
|  | 50 //---------------------------------- | 
|  | 51 // IE_Version | 
|  | 52 //---------------------------------- | 
|  | 53 | 
|  | 54 class IE_Version_Test | 
|  | 55   : public ::testing::Test | 
|  | 56 { | 
|  | 57 }; | 
|  | 58 | 
|  | 59 /* | 
|  | 60  * Exact version tests enabled by default. | 
|  | 61  * If they are disabled, gtext will report 2 disabled tests. | 
|  | 62  */ | 
|  | 63 #if !defined(DISABLE_EXACT_TESTS) | 
|  | 64 #define exact(x) exact_##x | 
|  | 65 #else | 
|  | 66 #define exact(x) DISABLED_exact_##x | 
|  | 67 #endif | 
|  | 68 /* | 
|  | 69  * Define a default version as the current version of IE in general release. | 
|  | 70  * Predefine on the command line to compile tests for non-standard development e
     nvironments. | 
|  | 71  */ | 
|  | 72 #ifndef INSTALLED_IE_VERSION | 
|  | 73 #define INSTALLED_IE_VERSION 11 | 
|  | 74 #endif | 
|  | 75 | 
|  | 76 TEST(IE_Version_Test, sanity_string) | 
|  | 77 { | 
|  | 78   std::wstring version = AdblockPlus::IE::InstalledVersionString(); | 
|  | 79   ASSERT_FALSE(version.length() == 0); // separate test for default value | 
|  | 80   ASSERT_TRUE(version.length() >= 2); | 
|  | 81 } | 
|  | 82 | 
|  | 83 TEST(IE_Version_Test, sanity_major) | 
|  | 84 { | 
|  | 85   int version = AdblockPlus::IE::InstalledMajorVersion(); | 
|  | 86   ASSERT_NE(version, 0); // separate test for default value | 
|  | 87   ASSERT_GE(version, 6); | 
|  | 88   ASSERT_LE(version, 12); | 
|  | 89   EXPECT_NE(version, 12); // This check will point out when the test needs updat
     ing. | 
|  | 90 } | 
|  | 91 | 
|  | 92 TEST(IE_Version_Test, exact(string)) | 
|  | 93 { | 
|  | 94     std::wstring version = AdblockPlus::IE::InstalledVersionString(); | 
|  | 95     std::wstring expected = std::to_wstring(INSTALLED_IE_VERSION) + L"."; | 
|  | 96     ASSERT_EQ(expected, version.substr(0, expected.length())); | 
|  | 97 } | 
|  | 98 | 
|  | 99 TEST(IE_Version_Test, exact(major)) | 
|  | 100 { | 
|  | 101   int version = AdblockPlus::IE::InstalledMajorVersion(); | 
|  | 102   ASSERT_EQ(version, INSTALLED_IE_VERSION); | 
|  | 103 } | 
| OLD | NEW | 
|---|