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

Side by Side Diff: test/FileSystemJsObject.cpp

Issue 29500602: Issue 5450 - introduce the Platform class (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 28, 2017, 12:40 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
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 content = jsEngine->Evaluate("result.content").AsString(); 121 content = jsEngine->Evaluate("result.content").AsString();
122 error = jsEngine->Evaluate("result.error").AsString(); 122 error = jsEngine->Evaluate("result.error").AsString();
123 } 123 }
124 124
125 typedef std::shared_ptr<MockFileSystem> MockFileSystemPtr; 125 typedef std::shared_ptr<MockFileSystem> MockFileSystemPtr;
126 126
127 class FileSystemJsObjectTest : public BaseJsTest 127 class FileSystemJsObjectTest : public BaseJsTest
128 { 128 {
129 protected: 129 protected:
130 MockFileSystemPtr mockFileSystem; 130 MockFileSystemPtr mockFileSystem;
131 AdblockPlus::JsEnginePtr jsEngine;
131 132
132 void SetUp() 133 void SetUp()
133 { 134 {
134 mockFileSystem = MockFileSystemPtr(new MockFileSystem); 135 mockFileSystem = MockFileSystemPtr(new MockFileSystem());
135 JsEngineCreationParameters params; 136 ThrowingPlatformCreationParameters params;
136 params.fileSystem = mockFileSystem; 137 params.fileSystem = mockFileSystem;
137 jsEngine = CreateJsEngine(std::move(params)); 138 platform.reset(new AdblockPlus::Platform(std::move(params)));
139 jsEngine = platform->GetJsEngine();
138 } 140 }
139 }; 141 };
140 } 142 }
141 143
142 TEST_F(FileSystemJsObjectTest, Read) 144 TEST_F(FileSystemJsObjectTest, Read)
143 { 145 {
144 mockFileSystem->contentToRead = 146 mockFileSystem->contentToRead =
145 AdblockPlus::IFileSystem::IOBuffer{'f', 'o', 'o'}; 147 AdblockPlus::IFileSystem::IOBuffer{'f', 'o', 'o'};
146 std::string content; 148 std::string content;
147 std::string error; 149 std::string error;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat()")); 251 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat()"));
250 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')")); 252 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')"));
251 } 253 }
252 254
253 TEST_F(FileSystemJsObjectTest, StatError) 255 TEST_F(FileSystemJsObjectTest, StatError)
254 { 256 {
255 mockFileSystem->success = false; 257 mockFileSystem->success = false;
256 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); 258 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})");
257 ASSERT_FALSE(jsEngine->Evaluate("result.error").IsUndefined()); 259 ASSERT_FALSE(jsEngine->Evaluate("result.error").IsUndefined());
258 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld