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

Delta Between Two Patch Sets: test/DefaultFileSystem.cpp

Issue 10296001: Implement File API (Closed)
Left Patch Set: Don't pass a blog to _fileSystem.write Created April 12, 2013, 12:10 p.m.
Right Patch Set: Addressed the new issues Created April 16, 2013, 1:37 p.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 | « src/Utils.cpp ('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 #include <AdblockPlus.h>
2 #include <gtest/gtest.h>
3
4 #include "../src/Utils.h"
5
6 namespace
7 {
8 const std::string testPath = "libadblockplus-test-file";
9
10 void WriteString(AdblockPlus::FileSystem& fileSystem,
11 const std::string& content)
12 {
13 std::tr1::shared_ptr<std::stringstream> input(new std::stringstream);
14 *input << content;
15 fileSystem.Write(testPath, input);
16 }
17 }
18
19 TEST(DefaultFileSystemTest, WriteReadRemove)
20 {
21 AdblockPlus::DefaultFileSystem fileSystem;
22 WriteString(fileSystem, "foo");
23 std::string output = AdblockPlus::Utils::Slurp(*fileSystem.Read(testPath));
24 fileSystem.Remove(testPath);
25 ASSERT_EQ("foo", output);
26 }
27
28 TEST(DefaultFileSystemTest, StatWorkingDirectory)
29 {
30 AdblockPlus::DefaultFileSystem fileSystem;
31 const AdblockPlus::FileSystem::StatResult result = fileSystem.Stat(".");
32 ASSERT_TRUE(result.exists);
33 ASSERT_TRUE(result.isDirectory);
34 ASSERT_FALSE(result.isFile);
35 ASSERT_NE(0, result.lastModified);
36 }
37
38 TEST(DefaultFileSystemTest, WriteMoveStatRemove)
39 {
40 AdblockPlus::DefaultFileSystem fileSystem;
41 WriteString(fileSystem, "foo");
42 AdblockPlus::FileSystem::StatResult result = fileSystem.Stat(testPath);
43 ASSERT_TRUE(result.exists);
44 ASSERT_TRUE(result.isFile);
45 ASSERT_FALSE(result.isDirectory);
46 ASSERT_NE(0, result.lastModified);
47 const std::string newTestPath = testPath + "-new";
48 fileSystem.Move(testPath, newTestPath);
49 result = fileSystem.Stat(testPath);
50 ASSERT_FALSE(result.exists);
51 result = fileSystem.Stat(newTestPath);
52 ASSERT_TRUE(result.exists);
53 fileSystem.Remove(newTestPath);
54 result = fileSystem.Stat(newTestPath);
55 ASSERT_FALSE(result.exists);
56 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld