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

Side by Side Diff: test/FileSystemJsObject.cpp

Issue 29535572: Issue 5183 - make FileSystemPtr std::unique_ptr (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created Sept. 4, 2017, 9:59 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
« no previous file with comments | « test/BaseJsTest.cpp ('k') | test/Prefs.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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 }; 106 };
107 107
108 void ReadFile(AdblockPlus::JsEngine& jsEngine, std::string& content, 108 void ReadFile(AdblockPlus::JsEngine& jsEngine, std::string& content,
109 std::string& error) 109 std::string& error)
110 { 110 {
111 jsEngine.Evaluate("let result; _fileSystem.read('', function(r) {result = r} )"); 111 jsEngine.Evaluate("let result; _fileSystem.read('', function(r) {result = r} )");
112 content = jsEngine.Evaluate("result.content").AsString(); 112 content = jsEngine.Evaluate("result.content").AsString();
113 error = jsEngine.Evaluate("result.error").AsString(); 113 error = jsEngine.Evaluate("result.error").AsString();
114 } 114 }
115 115
116 typedef std::shared_ptr<MockFileSystem> MockFileSystemPtr;
117
118 class FileSystemJsObjectTest : public BaseJsTest 116 class FileSystemJsObjectTest : public BaseJsTest
119 { 117 {
120 protected: 118 protected:
121 MockFileSystemPtr mockFileSystem; 119 MockFileSystem* mockFileSystem;
122 120
123 void SetUp() 121 void SetUp()
124 { 122 {
125 mockFileSystem = MockFileSystemPtr(new MockFileSystem());
126 ThrowingPlatformCreationParameters params; 123 ThrowingPlatformCreationParameters params;
127 params.fileSystem = mockFileSystem; 124 params.fileSystem.reset(mockFileSystem = new MockFileSystem());
128 platform.reset(new AdblockPlus::Platform(std::move(params))); 125 platform.reset(new AdblockPlus::Platform(std::move(params)));
129 } 126 }
130 }; 127 };
131 } 128 }
132 129
133 TEST_F(FileSystemJsObjectTest, Read) 130 TEST_F(FileSystemJsObjectTest, Read)
134 { 131 {
135 mockFileSystem->contentToRead = 132 mockFileSystem->contentToRead =
136 AdblockPlus::IFileSystem::IOBuffer{'f', 'o', 'o'}; 133 AdblockPlus::IFileSystem::IOBuffer{'f', 'o', 'o'};
137 std::string content; 134 std::string content;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 (error) => 395 (error) =>
399 { 396 {
400 if (error) 397 if (error)
401 _triggerEvent("onDone", error); 398 _triggerEvent("onDone", error);
402 else 399 else
403 _triggerEvent("onDone"); 400 _triggerEvent("onDone");
404 });)js"); 401 });)js");
405 EXPECT_EQ(2u, readLines.size()); 402 EXPECT_EQ(2u, readLines.size());
406 EXPECT_EQ("Error: my-error at undefined:8", error); 403 EXPECT_EQ("Error: my-error at undefined:8", error);
407 } 404 }
OLDNEW
« no previous file with comments | « test/BaseJsTest.cpp ('k') | test/Prefs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld