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

Side by Side Diff: test/Notification.cpp

Issue 29499583: Issue 4938 - fix race conditions related to LazyFileSystem (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 27, 2017, 8:53 a.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 15 matching lines...) Expand all
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 FilterEnginePtr filterEngine; 33 FilterEnginePtr filterEngine;
34 void SetUp() 34 void SetUp()
35 { 35 {
36 LazyFileSystem* fileSystem;
36 JsEngineCreationParameters jsEngineParams; 37 JsEngineCreationParameters jsEngineParams;
37 jsEngineParams.fileSystem.reset(new LazyFileSystem()); 38 jsEngineParams.fileSystem.reset(fileSystem = new LazyFileSystem());
38 jsEngineParams.logSystem.reset(new DefaultLogSystem()); 39 jsEngineParams.logSystem.reset(new DefaultLogSystem());
39 jsEngineParams.timer.reset(new NoopTimer()); 40 jsEngineParams.timer.reset(new NoopTimer());
40 jsEngineParams.webRequest.reset(new NoopWebRequest()); 41 jsEngineParams.webRequest.reset(new NoopWebRequest());
41 auto jsEngine = CreateJsEngine(std::move(jsEngineParams)); 42 auto jsEngine = CreateJsEngine(std::move(jsEngineParams));
42 filterEngine = FilterEngine::Create(jsEngine); 43 filterEngine = CreateFilterEngine(*fileSystem, jsEngine);
43 } 44 }
44 45
45 void AddNotification(const std::string& notification) 46 void AddNotification(const std::string& notification)
46 { 47 {
47 filterEngine->GetJsEngine()->Evaluate("(function()" 48 filterEngine->GetJsEngine()->Evaluate("(function()"
48 "{" 49 "{"
49 "require('notification').Notification.addNotification(" + notification + ");" 50 "require('notification').Notification.addNotification(" + notification + ");"
50 "})();"); 51 "})();");
51 } 52 }
52 53
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 TEST_F(NotificationTest, Links) 197 TEST_F(NotificationTest, Links)
197 { 198 {
198 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); 199 AddNotification("{ id: 'id', links: ['link1', 'link2'] }");
199 auto notification = PeekNotification(); 200 auto notification = PeekNotification();
200 ASSERT_TRUE(notification); 201 ASSERT_TRUE(notification);
201 std::vector<std::string> notificationLinks = notification->GetLinks(); 202 std::vector<std::string> notificationLinks = notification->GetLinks();
202 ASSERT_EQ(2u, notificationLinks.size()); 203 ASSERT_EQ(2u, notificationLinks.size());
203 EXPECT_EQ("link1", notificationLinks[0]); 204 EXPECT_EQ("link1", notificationLinks[0]);
204 EXPECT_EQ("link2", notificationLinks[1]); 205 EXPECT_EQ("link2", notificationLinks[1]);
205 } 206 }
OLDNEW
« test/FilterEngine.cpp ('K') | « test/FilterEngine.cpp ('k') | test/Prefs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld