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

Side by Side Diff: test/JsEngine.cpp

Issue 29410664: Issue 5013 - Use const JsValue and pass reference where applicable (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Fixed comment Created April 13, 2017, 3:45 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
« no previous file with comments | « test/FilterEngine.cpp ('k') | test/UpdateCheck.cpp » ('j') | 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-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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ASSERT_TRUE(value->AsBool()); 60 ASSERT_TRUE(value->AsBool());
61 61
62 value = jsEngine->NewObject(); 62 value = jsEngine->NewObject();
63 ASSERT_TRUE(value->IsObject()); 63 ASSERT_TRUE(value->IsObject());
64 ASSERT_EQ(0u, value->GetOwnPropertyNames().size()); 64 ASSERT_EQ(0u, value->GetOwnPropertyNames().size());
65 } 65 }
66 66
67 TEST_F(JsEngineTest, EventCallbacks) 67 TEST_F(JsEngineTest, EventCallbacks)
68 { 68 {
69 bool callbackCalled = false; 69 bool callbackCalled = false;
70 AdblockPlus::JsValueList callbackParams; 70 AdblockPlus::JsConstValueList callbackParams;
71 auto Callback = [&callbackCalled, & callbackParams]( 71 auto Callback = [&callbackCalled, & callbackParams](
72 const AdblockPlus::JsValueList& params) 72 const AdblockPlus::JsConstValueList& params)
73 { 73 {
74 callbackCalled = true; 74 callbackCalled = true;
75 callbackParams = params; 75 callbackParams = params;
76 }; 76 };
77 77
78 // Trigger event without a callback 78 // Trigger event without a callback
79 callbackCalled = false; 79 callbackCalled = false;
80 jsEngine->Evaluate("_triggerEvent('foobar')"); 80 jsEngine->Evaluate("_triggerEvent('foobar')");
81 ASSERT_FALSE(callbackCalled); 81 ASSERT_FALSE(callbackCalled);
82 82
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 TEST(NewJsEngineTest, GlobalPropertyTest) 128 TEST(NewJsEngineTest, GlobalPropertyTest)
129 { 129 {
130 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New()); 130 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New());
131 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar")); 131 jsEngine->SetGlobalProperty("foo", jsEngine->NewValue("bar"));
132 AdblockPlus::JsValuePtr foo = jsEngine->Evaluate("foo"); 132 AdblockPlus::JsValuePtr foo = jsEngine->Evaluate("foo");
133 ASSERT_TRUE(foo->IsString()); 133 ASSERT_TRUE(foo->IsString());
134 ASSERT_EQ(foo->AsString(), "bar"); 134 ASSERT_EQ(foo->AsString(), "bar");
135 } 135 }
136 136
OLDNEW
« no previous file with comments | « test/FilterEngine.cpp ('k') | test/UpdateCheck.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld