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

Delta Between Two Patch Sets: test/DefaultFileSystem.cpp

Issue 10488022: Added Android build target (Closed)
Left Patch Set: Created May 16, 2013, 10:23 a.m.
Right Patch Set: Review comments addressed Created May 24, 2013, 8:40 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « libadblockplus.gyp ('k') | test/FileSystemJsObject.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <sstream>
18 #include <AdblockPlus.h> 19 #include <AdblockPlus.h>
19 #include <gtest/gtest.h> 20 #include <gtest/gtest.h>
20
21 #include "../src/Utils.h"
22 21
23 namespace 22 namespace
24 { 23 {
25 const std::string testPath = "libadblockplus-t\xc3\xa4st-file"; 24 const std::string testPath = "libadblockplus-t\xc3\xa4st-file";
26 25
27 void WriteString(AdblockPlus::FileSystem& fileSystem, 26 void WriteString(AdblockPlus::FileSystem& fileSystem,
28 const std::string& content) 27 const std::string& content)
29 { 28 {
30 std::tr1::shared_ptr<std::stringstream> input(new std::stringstream); 29 std::tr1::shared_ptr<std::stringstream> input(new std::stringstream);
31 *input << content; 30 *input << content;
32 fileSystem.Write(testPath, input); 31 fileSystem.Write(testPath, input);
33 } 32 }
34 } 33 }
35 34
36 TEST(DefaultFileSystemTest, WriteReadRemove) 35 TEST(DefaultFileSystemTest, WriteReadRemove)
37 { 36 {
38 AdblockPlus::DefaultFileSystem fileSystem; 37 AdblockPlus::DefaultFileSystem fileSystem;
39 WriteString(fileSystem, "foo"); 38 WriteString(fileSystem, "foo");
40 std::string output = AdblockPlus::Utils::Slurp(*fileSystem.Read(testPath)); 39 std::stringstream output;
40 output << fileSystem.Read(testPath)->rdbuf();
41 fileSystem.Remove(testPath); 41 fileSystem.Remove(testPath);
42 ASSERT_EQ("foo", output); 42 ASSERT_EQ("foo", output.str());
43 } 43 }
44 44
45 TEST(DefaultFileSystemTest, StatWorkingDirectory) 45 TEST(DefaultFileSystemTest, StatWorkingDirectory)
46 { 46 {
47 AdblockPlus::DefaultFileSystem fileSystem; 47 AdblockPlus::DefaultFileSystem fileSystem;
48 const AdblockPlus::FileSystem::StatResult result = fileSystem.Stat("."); 48 const AdblockPlus::FileSystem::StatResult result = fileSystem.Stat(".");
49 ASSERT_TRUE(result.exists); 49 ASSERT_TRUE(result.exists);
50 ASSERT_TRUE(result.isDirectory); 50 ASSERT_TRUE(result.isDirectory);
51 ASSERT_FALSE(result.isFile); 51 ASSERT_FALSE(result.isFile);
52 ASSERT_NE(0, result.lastModified); 52 ASSERT_NE(0, result.lastModified);
(...skipping 11 matching lines...) Expand all
64 const std::string newTestPath = testPath + "-new"; 64 const std::string newTestPath = testPath + "-new";
65 fileSystem.Move(testPath, newTestPath); 65 fileSystem.Move(testPath, newTestPath);
66 result = fileSystem.Stat(testPath); 66 result = fileSystem.Stat(testPath);
67 ASSERT_FALSE(result.exists); 67 ASSERT_FALSE(result.exists);
68 result = fileSystem.Stat(newTestPath); 68 result = fileSystem.Stat(newTestPath);
69 ASSERT_TRUE(result.exists); 69 ASSERT_TRUE(result.exists);
70 fileSystem.Remove(newTestPath); 70 fileSystem.Remove(newTestPath);
71 result = fileSystem.Stat(newTestPath); 71 result = fileSystem.Stat(newTestPath);
72 ASSERT_FALSE(result.exists); 72 ASSERT_FALSE(result.exists);
73 } 73 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld