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

Delta Between Two Patch Sets: test/Notification.cpp

Issue 5708936187478016: Issue 1906 - Fix broken Android build (Closed)
Left Patch Set: Created Jan. 29, 2015, 2:16 p.m.
Right Patch Set: Fixed some formatting issues, shared_ptr.reset() Created Jan. 29, 2015, 5:07 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « libadblockplus.gyp ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 = 40 filterEngine.reset(new FilterEngine(jsEngine));
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.
42 } 41 }
43 42
44 void AddNotification(const std::string& notification) 43 void AddNotification(const std::string& notification)
45 { 44 {
46 jsEngine->Evaluate("(function()" 45 jsEngine->Evaluate("(function()"
47 "{" 46 "{"
48 "require('notification').Notification.addNotification(" + notification + ");" 47 "require('notification').Notification.addNotification(" + notification + ");"
49 "})();"); 48 "})();");
50 } 49 }
51 }; 50 };
(...skipping 23 matching lines...) Expand all
75 74
76 #ifdef NotificationMockWebRequestTest_ENABLED 75 #ifdef NotificationMockWebRequestTest_ENABLED
77 class NotificationMockWebRequestTest : public BaseJsTest 76 class NotificationMockWebRequestTest : public BaseJsTest
78 { 77 {
79 protected: 78 protected:
80 FilterEnginePtr filterEngine; 79 FilterEnginePtr filterEngine;
81 void SetUp() override 80 void SetUp() override
82 { 81 {
83 BaseJsTest::SetUp(); 82 BaseJsTest::SetUp();
84 jsEngine->SetFileSystem( 83 jsEngine->SetFileSystem(
85 std::tr1::shared_ptr<LazyFileSystem>(new LazyFileSystem())); 84 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.
86 const char* responseJsonText = "{" 85 const char* responseJsonText = "{"
87 "\"notifications\": [{" 86 "\"notifications\": [{"
88 "\"id\": \"some id\"," 87 "\"id\": \"some id\","
89 "\"type\": \"information\"," 88 "\"type\": \"information\","
90 "\"message\": {" 89 "\"message\": {"
91 "\"en-US\": \"message\"" 90 "\"en-US\": \"message\""
92 "}," 91 "},"
93 "\"title\": \"Title\"" 92 "\"title\": \"Title\""
94 "}]" 93 "}]"
95 "}"; 94 "}";
96 jsEngine->SetWebRequest(std::tr1::shared_ptr<MockWebRequest>( 95 jsEngine->SetWebRequest(std::tr1::shared_ptr<MockWebRequest>(
97 new MockWebRequest(responseJsonText))); 96 new MockWebRequest(responseJsonText)));
98 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); 97 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem()));
99 filterEngine = 98 filterEngine.reset(new FilterEngine(jsEngine));
100 std::tr1::shared_ptr<FilterEngine>(new FilterEngine(jsEngine));
101 } 99 }
102 }; 100 };
103 #endif 101 #endif
104 } 102 }
105 103
106 TEST_F(NotificationTest, NoNotifications) 104 TEST_F(NotificationTest, NoNotifications)
107 { 105 {
108 NotificationPtr notification = filterEngine->GetNextNotificationToShow(); 106 NotificationPtr notification = filterEngine->GetNextNotificationToShow();
109 EXPECT_EQ(NULL, notification.get()); 107 EXPECT_EQ(NULL, notification.get());
110 } 108 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 TEST_F(NotificationTest, MarkAsShown) 162 TEST_F(NotificationTest, MarkAsShown)
165 { 163 {
166 AddNotification("{ id: 'id', type: 'question' }"); 164 AddNotification("{ id: 'id', type: 'question' }");
167 NotificationPtr notification = filterEngine->GetNextNotificationToShow(); 165 NotificationPtr notification = filterEngine->GetNextNotificationToShow();
168 EXPECT_TRUE(notification); 166 EXPECT_TRUE(notification);
169 notification = filterEngine->GetNextNotificationToShow(); 167 notification = filterEngine->GetNextNotificationToShow();
170 ASSERT_TRUE(notification); 168 ASSERT_TRUE(notification);
171 notification->MarkAsShown(); 169 notification->MarkAsShown();
172 EXPECT_EQ(NULL, filterEngine->GetNextNotificationToShow().get()); 170 EXPECT_EQ(NULL, filterEngine->GetNextNotificationToShow().get());
173 } 171 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld