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

Side by Side Diff: test/Notification.cpp

Issue 29500602: Issue 5450 - introduce the Platform class (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 28, 2017, 12:40 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
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-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
(...skipping 12 matching lines...) Expand all
23 // one need to set INITIAL_DELAY to about 2000 msec in notification.js. 23 // one need to set INITIAL_DELAY to about 2000 msec in notification.js.
24 //#define NotificationMockWebRequestTest_ENABLED 24 //#define NotificationMockWebRequestTest_ENABLED
25 25
26 namespace 26 namespace
27 { 27 {
28 typedef std::shared_ptr<FilterEngine> FilterEnginePtr; 28 typedef std::shared_ptr<FilterEngine> FilterEnginePtr;
29 29
30 class NotificationTest : public ::testing::Test 30 class NotificationTest : public ::testing::Test
31 { 31 {
32 protected: 32 protected:
33 std::unique_ptr<Platform> platform;
33 FilterEnginePtr filterEngine; 34 FilterEnginePtr filterEngine;
34 void SetUp() 35 void SetUp()
35 { 36 {
36 LazyFileSystem* fileSystem; 37 LazyFileSystem* fileSystem;
37 JsEngineCreationParameters jsEngineParams; 38 ThrowingPlatformCreationParameters platformParams;
38 jsEngineParams.fileSystem.reset(fileSystem = new LazyFileSystem()); 39 platformParams.timer.reset(new NoopTimer());
39 jsEngineParams.logSystem.reset(new DefaultLogSystem()); 40 platformParams.fileSystem.reset(fileSystem = new LazyFileSystem());
40 jsEngineParams.timer.reset(new NoopTimer()); 41 platformParams.webRequest.reset(new NoopWebRequest());
41 jsEngineParams.webRequest.reset(new NoopWebRequest()); 42 platform.reset(new Platform(std::move(platformParams)));
42 auto jsEngine = CreateJsEngine(std::move(jsEngineParams)); 43 filterEngine = CreateFilterEngine(*fileSystem, platform->GetJsEngine());
43 filterEngine = CreateFilterEngine(*fileSystem, jsEngine);
44 } 44 }
45 45
46 void AddNotification(const std::string& notification) 46 void AddNotification(const std::string& notification)
47 { 47 {
48 filterEngine->GetJsEngine()->Evaluate("(function()" 48 filterEngine->GetJsEngine()->Evaluate("(function()"
49 "{" 49 "{"
50 "require('notification').Notification.addNotification(" + notification + ");" 50 "require('notification').Notification.addNotification(" + notification + ");"
51 "})();"); 51 "})();");
52 } 52 }
53 53
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 TEST_F(NotificationTest, Links) 197 TEST_F(NotificationTest, Links)
198 { 198 {
199 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); 199 AddNotification("{ id: 'id', links: ['link1', 'link2'] }");
200 auto notification = PeekNotification(); 200 auto notification = PeekNotification();
201 ASSERT_TRUE(notification); 201 ASSERT_TRUE(notification);
202 std::vector<std::string> notificationLinks = notification->GetLinks(); 202 std::vector<std::string> notificationLinks = notification->GetLinks();
203 ASSERT_EQ(2u, notificationLinks.size()); 203 ASSERT_EQ(2u, notificationLinks.size());
204 EXPECT_EQ("link1", notificationLinks[0]); 204 EXPECT_EQ("link1", notificationLinks[0]);
205 EXPECT_EQ("link2", notificationLinks[1]); 205 EXPECT_EQ("link2", notificationLinks[1]);
206 } 206 }
OLDNEW
« include/AdblockPlus/JsEngine.h ('K') | « test/JsValue.cpp ('k') | test/Prefs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld