OLD | NEW |
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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 <AdblockPlus.h> | 18 #include <AdblockPlus.h> |
19 #include <gtest/gtest.h> | 19 #include <gtest/gtest.h> |
| 20 #include "BaseJsTest.h" |
20 | 21 |
21 TEST(AppInfoJsObjectTest, AllProperties) | 22 TEST(AppInfoJsObjectTest, AllProperties) |
22 { | 23 { |
23 AdblockPlus::AppInfo appInfo; | 24 AdblockPlus::AppInfo appInfo; |
24 appInfo.version = "1"; | 25 appInfo.version = "1"; |
25 appInfo.name = "3"; | 26 appInfo.name = "3"; |
26 appInfo.application = "4"; | 27 appInfo.application = "4"; |
27 appInfo.applicationVersion = "5"; | 28 appInfo.applicationVersion = "5"; |
28 appInfo.locale = "2"; | 29 appInfo.locale = "2"; |
29 appInfo.developmentBuild = true; | 30 appInfo.developmentBuild = true; |
30 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New(appInfo)); | 31 AdblockPlus::Platform platform{ThrowingPlatformCreationParameters()}; |
31 ASSERT_EQ("1", jsEngine->Evaluate("_appInfo.version").AsString()); | 32 platform.SetUpJsEngine(appInfo); |
32 ASSERT_EQ("3", jsEngine->Evaluate("_appInfo.name").AsString()); | 33 ASSERT_EQ("1", platform.GetJsEngine()->Evaluate("_appInfo.version").AsString()
); |
33 ASSERT_EQ("4", jsEngine->Evaluate("_appInfo.application").AsString()); | 34 ASSERT_EQ("3", platform.GetJsEngine()->Evaluate("_appInfo.name").AsString()); |
34 ASSERT_EQ("5", jsEngine->Evaluate("_appInfo.applicationVersion").AsString()); | 35 ASSERT_EQ("4", platform.GetJsEngine()->Evaluate("_appInfo.application").AsStri
ng()); |
35 ASSERT_EQ("2", jsEngine->Evaluate("_appInfo.locale").AsString()); | 36 ASSERT_EQ("5", platform.GetJsEngine()->Evaluate("_appInfo.applicationVersion")
.AsString()); |
36 ASSERT_TRUE(jsEngine->Evaluate("_appInfo.developmentBuild").AsBool()); | 37 ASSERT_EQ("2", platform.GetJsEngine()->Evaluate("_appInfo.locale").AsString())
; |
| 38 ASSERT_TRUE(platform.GetJsEngine()->Evaluate("_appInfo.developmentBuild").AsBo
ol()); |
37 } | 39 } |
38 | 40 |
39 TEST(AppInfoJsObjectTest, DefaultPropertyValues) | 41 TEST(AppInfoJsObjectTest, DefaultPropertyValues) |
40 { | 42 { |
41 AdblockPlus::AppInfo appInfo; | 43 AdblockPlus::Platform platform{ThrowingPlatformCreationParameters()}; |
42 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New(appInfo)); | 44 platform.SetUpJsEngine(); |
43 ASSERT_EQ("", jsEngine->Evaluate("_appInfo.version").AsString()); | 45 ASSERT_EQ("", platform.GetJsEngine()->Evaluate("_appInfo.version").AsString())
; |
44 ASSERT_EQ("", jsEngine->Evaluate("_appInfo.name").AsString()); | 46 ASSERT_EQ("", platform.GetJsEngine()->Evaluate("_appInfo.name").AsString()); |
45 ASSERT_EQ("", jsEngine->Evaluate("_appInfo.application").AsString()); | 47 ASSERT_EQ("", platform.GetJsEngine()->Evaluate("_appInfo.application").AsStrin
g()); |
46 ASSERT_EQ("", jsEngine->Evaluate("_appInfo.applicationVersion").AsString()); | 48 ASSERT_EQ("", platform.GetJsEngine()->Evaluate("_appInfo.applicationVersion").
AsString()); |
47 ASSERT_EQ("", jsEngine->Evaluate("_appInfo.locale").AsString()); | 49 ASSERT_EQ("", platform.GetJsEngine()->Evaluate("_appInfo.locale").AsString()); |
48 ASSERT_FALSE(jsEngine->Evaluate("_appInfo.developmentBuild").AsBool()); | 50 ASSERT_FALSE(platform.GetJsEngine()->Evaluate("_appInfo.developmentBuild").AsB
ool()); |
49 } | 51 } |
OLD | NEW |