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

Unified Diff: common/test/IeVersionTest.cpp

Issue 6216090891845632: Issue #404 - Create common library shared between plugin/engine and installer (Closed)
Patch Set: Rename to IeVersion*.*; fix URL in copyright notice Created Feb. 27, 2015, 1:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: common/test/IeVersionTest.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/common/test/IeVersionTest.cpp
@@ -0,0 +1,65 @@
+/*
+ * This file is part of Adblock Plus <http://adblockplus.org/>,
+ * Copyright (C) 2006-2015 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtest/gtest.h>
+#include "IE_Version.h"
+
+/*
+ * Exact version tests enabled by default.
+ * If they are disabled, gtext will report 2 disabled tests.
sergei 2015/03/04 15:53:56 Just to note, gtest, not gtext.
Eric 2015/03/04 16:55:10 Done.
+ */
+#if !defined(DISABLE_EXACT_TESTS)
Oleksandr 2015/03/04 15:37:23 How about just using if !defined(INSTALLED_IE_VERS
Eric 2015/03/04 16:55:10 If we change it, we can change it elsewhere and la
Felix Dahlke 2015/03/05 13:33:06 The code is being introduced here - if we want to
Eric 2015/03/05 14:49:48 It is not being introduced here. It's being moved
+#define exact(x) Exact##x
+#else
+#define exact(x) DISABLED_Exact##x
+#endif
+/*
+ * Define a default version as the current version of IE in general release.
+ * Predefine on the command line to compile tests for non-standard development environments.
+ */
+#ifndef INSTALLED_IE_VERSION
+#define INSTALLED_IE_VERSION 11
+#endif
+
+TEST(InstalledVersionStringTest, Sanity)
+{
+ std::wstring version = AdblockPlus::IE::InstalledVersionString();
+ ASSERT_FALSE(version.length() == 0); // separate test for default value
+ ASSERT_TRUE(version.length() >= 2);
+}
+
+TEST(InstalledMajorVersionTest, Sanity)
+{
+ int version = AdblockPlus::IE::InstalledMajorVersion();
+ ASSERT_NE(version, 0); // separate test for default value
+ ASSERT_GE(version, 6);
+ ASSERT_LE(version, 12);
+ EXPECT_NE(version, 12); // This check will point out when the test needs updating.
+}
+
+TEST(InstalledVersionStringTest, exact(PrefixOnly))
+{
+ std::wstring version = AdblockPlus::IE::InstalledVersionString();
+ std::wstring expected = std::to_wstring(INSTALLED_IE_VERSION) + L".";
+ ASSERT_EQ(expected, version.substr(0, expected.length()));
+}
+
+TEST(InstalledMajorVersionTest, exact(MajorOnly))
+{
+ int version = AdblockPlus::IE::InstalledMajorVersion();
+ ASSERT_EQ(version, INSTALLED_IE_VERSION);
+}

Powered by Google App Engine
This is Rietveld