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

Side by Side Diff: test/Notification.cpp

Issue 5708936187478016: Issue 1906 - Fix broken Android build (Closed)
Patch Set: Created Jan. 29, 2015, 2:16 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
« libadblockplus.gyp ('K') | « libadblockplus.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 19 matching lines...) Expand all
30 class NotificationTest : public BaseJsTest 30 class NotificationTest : public BaseJsTest
31 { 31 {
32 protected: 32 protected:
33 FilterEnginePtr filterEngine; 33 FilterEnginePtr filterEngine;
34 void SetUp() override 34 void SetUp() override
35 { 35 {
36 BaseJsTest::SetUp(); 36 BaseJsTest::SetUp();
37 jsEngine->SetFileSystem(FileSystemPtr(new LazyFileSystem())); 37 jsEngine->SetFileSystem(FileSystemPtr(new LazyFileSystem()));
38 jsEngine->SetWebRequest(WebRequestPtr(new LazyWebRequest())); 38 jsEngine->SetWebRequest(WebRequestPtr(new LazyWebRequest()));
39 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); 39 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem()));
40 filterEngine = std::tr1::make_shared<FilterEngine>(jsEngine); 40 filterEngine =
41 std::tr1::shared_ptr<FilterEngine>(new FilterEngine(jsEngine));
René Jeschke 2015/01/29 14:22:22 std::tr1::make_shared<T>(...) is not available on
Felix Dahlke 2015/01/29 16:49:25 We can actually go for the shorter: filterEngine.
René Jeschke 2015/01/29 17:07:53 Done.
41 } 42 }
42 43
43 void AddNotification(const std::string& notification) 44 void AddNotification(const std::string& notification)
44 { 45 {
45 jsEngine->Evaluate("(function()" 46 jsEngine->Evaluate("(function()"
46 "{" 47 "{"
47 "require('notification').Notification.addNotification(" + notification + ");" 48 "require('notification').Notification.addNotification(" + notification + ");"
48 "})();"); 49 "})();");
49 } 50 }
50 }; 51 };
(...skipping 22 matching lines...) Expand all
73 }; 74 };
74 75
75 #ifdef NotificationMockWebRequestTest_ENABLED 76 #ifdef NotificationMockWebRequestTest_ENABLED
76 class NotificationMockWebRequestTest : public BaseJsTest 77 class NotificationMockWebRequestTest : public BaseJsTest
77 { 78 {
78 protected: 79 protected:
79 FilterEnginePtr filterEngine; 80 FilterEnginePtr filterEngine;
80 void SetUp() override 81 void SetUp() override
81 { 82 {
82 BaseJsTest::SetUp(); 83 BaseJsTest::SetUp();
83 jsEngine->SetFileSystem(std::tr1::make_shared<LazyFileSystem>()); 84 jsEngine->SetFileSystem(
85 std::tr1::shared_ptr<LazyFileSystem>(new LazyFileSystem()));
Felix Dahlke 2015/01/29 16:49:25 Next line indent is generally 2 spaces, apparent a
René Jeschke 2015/01/29 17:07:53 Done.
84 const char* responseJsonText = "{" 86 const char* responseJsonText = "{"
85 "\"notifications\": [{" 87 "\"notifications\": [{"
86 "\"id\": \"some id\"," 88 "\"id\": \"some id\","
87 "\"type\": \"information\"," 89 "\"type\": \"information\","
88 "\"message\": {" 90 "\"message\": {"
89 "\"en-US\": \"message\"" 91 "\"en-US\": \"message\""
90 "}," 92 "},"
91 "\"title\": \"Title\"" 93 "\"title\": \"Title\""
92 "}]" 94 "}]"
93 "}"; 95 "}";
94 jsEngine->SetWebRequest(std::tr1::make_shared<MockWebRequest>(responseJson Text)); 96 jsEngine->SetWebRequest(std::tr1::shared_ptr<MockWebRequest>(
97 new MockWebRequest(responseJsonText)));
95 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); 98 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem()));
96 filterEngine = std::tr1::make_shared<FilterEngine>(jsEngine); 99 filterEngine =
100 std::tr1::shared_ptr<FilterEngine>(new FilterEngine(jsEngine));
97 } 101 }
98 }; 102 };
99 #endif 103 #endif
100 } 104 }
101 105
102 TEST_F(NotificationTest, NoNotifications) 106 TEST_F(NotificationTest, NoNotifications)
103 { 107 {
104 NotificationPtr notification = filterEngine->GetNextNotificationToShow(); 108 NotificationPtr notification = filterEngine->GetNextNotificationToShow();
105 EXPECT_EQ(NULL, notification.get()); 109 EXPECT_EQ(NULL, notification.get());
106 } 110 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 163
160 TEST_F(NotificationTest, MarkAsShown) 164 TEST_F(NotificationTest, MarkAsShown)
161 { 165 {
162 AddNotification("{ id: 'id', type: 'question' }"); 166 AddNotification("{ id: 'id', type: 'question' }");
163 NotificationPtr notification = filterEngine->GetNextNotificationToShow(); 167 NotificationPtr notification = filterEngine->GetNextNotificationToShow();
164 EXPECT_TRUE(notification); 168 EXPECT_TRUE(notification);
165 notification = filterEngine->GetNextNotificationToShow(); 169 notification = filterEngine->GetNextNotificationToShow();
166 ASSERT_TRUE(notification); 170 ASSERT_TRUE(notification);
167 notification->MarkAsShown(); 171 notification->MarkAsShown();
168 EXPECT_EQ(NULL, filterEngine->GetNextNotificationToShow().get()); 172 EXPECT_EQ(NULL, filterEngine->GetNextNotificationToShow().get());
169 } 173 }
OLDNEW
« libadblockplus.gyp ('K') | « libadblockplus.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld