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

Delta Between Two Patch Sets: test/Notification.cpp

Issue 29317074: Issue 2693 - Update adblockplus dependency (Closed)
Left Patch Set: address comments Created July 1, 2015, 11:43 a.m.
Right Patch Set: rebase Created July 2, 2015, 1:37 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 | « src/FilterEngine.cpp ('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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 serverResponse.responseText = responseText; 87 serverResponse.responseText = responseText;
88 return serverResponse; 88 return serverResponse;
89 } 89 }
90 }; 90 };
91 91
92 #ifdef NotificationMockWebRequestTest_ENABLED 92 #ifdef NotificationMockWebRequestTest_ENABLED
93 class NotificationMockWebRequestTest : public BaseJsTest 93 class NotificationMockWebRequestTest : public BaseJsTest
94 { 94 {
95 protected: 95 protected:
96 FilterEnginePtr filterEngine; 96 FilterEnginePtr filterEngine;
97 bool isNotificationCallbackCalled;
97 void SetUp() 98 void SetUp()
98 { 99 {
99 BaseJsTest::SetUp(); 100 BaseJsTest::SetUp();
100 isNotificationCallbackCalled = false; 101 isNotificationCallbackCalled = false;
101 jsEngine->SetFileSystem( 102 jsEngine->SetFileSystem(
102 std::tr1::shared_ptr<LazyFileSystem>(new LazyFileSystem())); 103 std::tr1::shared_ptr<LazyFileSystem>(new LazyFileSystem()));
103 const char* responseJsonText = "{" 104 const char* responseJsonText = "{"
104 "\"notifications\": [{" 105 "\"notifications\": [{"
105 "\"id\": \"some id\"," 106 "\"id\": \"some id\","
106 "\"type\": \"information\"," 107 "\"type\": \"information\","
107 "\"message\": {" 108 "\"message\": {"
108 "\"en-US\": \"message\"" 109 "\"en-US\": \"message\""
109 "}," 110 "},"
110 "\"title\": \"Title\"" 111 "\"title\": \"Title\""
111 "}]" 112 "}]"
112 "}"; 113 "}";
113 jsEngine->SetWebRequest(std::tr1::shared_ptr<MockWebRequest>( 114 jsEngine->SetWebRequest(std::tr1::shared_ptr<MockWebRequest>(
114 new MockWebRequest(responseJsonText))); 115 new MockWebRequest(responseJsonText)));
115 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem())); 116 jsEngine->SetLogSystem(LogSystemPtr(new DefaultLogSystem()));
116 filterEngine.reset(new FilterEngine(jsEngine)); 117 filterEngine.reset(new FilterEngine(jsEngine));
117 filterEngine->SetShowNotificationCallback( 118 filterEngine->SetShowNotificationCallback(
118 std::bind(&NotificationMockWebRequestTest::onNotification, 119 std::bind(&NotificationMockWebRequestTest::OnNotification,
119 this, std::tr1::placeholders::_1)); 120 this, std::tr1::placeholders::_1));
120 } 121 }
121 122
122 void onNotification(const NotificationPtr& notification) 123 void OnNotification(const NotificationPtr& notification)
Felix Dahlke 2015/07/02 13:23:13 Nit: Function names should start with an upper cas
123 { 124 {
124 isNotificationCallbackCalled = true; 125 isNotificationCallbackCalled = true;
125 ASSERT_TRUE(notification); 126 ASSERT_TRUE(notification);
126 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notification->G etType()); 127 EXPECT_EQ(NotificationType::NOTIFICATION_TYPE_INFORMATION, notification->G etType());
127 EXPECT_EQ("Title", notification->GetTitle()); 128 EXPECT_EQ("Title", notification->GetTitle());
128 EXPECT_EQ("message", notification->GetMessageString()); 129 EXPECT_EQ("message", notification->GetMessageString());
129 notification->MarkAsShown(); 130 notification->MarkAsShown();
130 } 131 }
131 bool isNotificationCallbackCalled;
Felix Dahlke 2015/07/02 13:23:13 Optional nit: Possibly just personal preference, b
132 }; 132 };
133 #endif 133 #endif
134 } 134 }
135 135
136 TEST_F(NotificationTest, NoNotifications) 136 TEST_F(NotificationTest, NoNotifications)
137 { 137 {
138 EXPECT_FALSE(PeekNotification()); 138 EXPECT_FALSE(PeekNotification());
139 } 139 }
140 140
141 #ifdef NotificationMockWebRequestTest_ENABLED 141 #ifdef NotificationMockWebRequestTest_ENABLED
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 TEST_F(NotificationTest, Links) 204 TEST_F(NotificationTest, Links)
205 { 205 {
206 AddNotification("{ id: 'id', links: ['link1', 'link2'] }"); 206 AddNotification("{ id: 'id', links: ['link1', 'link2'] }");
207 NotificationPtr notification = PeekNotification(); 207 NotificationPtr notification = PeekNotification();
208 ASSERT_TRUE(notification); 208 ASSERT_TRUE(notification);
209 std::vector<std::string> notificationLinks = notification->GetLinks(); 209 std::vector<std::string> notificationLinks = notification->GetLinks();
210 ASSERT_EQ(2, notificationLinks.size()); 210 ASSERT_EQ(2, notificationLinks.size());
211 EXPECT_EQ("link1", notificationLinks[0]); 211 EXPECT_EQ("link1", notificationLinks[0]);
212 EXPECT_EQ("link2", notificationLinks[1]); 212 EXPECT_EQ("link2", notificationLinks[1]);
213 } 213 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld