Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: chrome/browser/local_discovery/storage/privet_filesystem_attribute_cache_unittest.cc

Issue 492693004: Delete Privet filesystem code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/files/file_path.h"
6 #include "base/json/json_reader.h"
7 #include "chrome/browser/local_discovery/storage/privet_filesystem_attribute_cac he.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9
10 namespace local_discovery {
11
12 namespace {
13
14 const char kPrivetStorageJSON[] =
15 "{"
16 " \"name\": \"foo\","
17 " \"type\": \"dir\","
18 " \"entries\" : [ "
19 " { \"name\": \"bar\", \"type\": \"dir\" },"
20 " { \"name\": \"baz.txt\", \"type\": \"file\", \"size\": 12345 }"
21 " ]}";
22
23 class PrivetFileSystemAttributeCacheTest : public ::testing::Test {
24 public:
25 PrivetFileSystemAttributeCacheTest() {}
26
27 virtual ~PrivetFileSystemAttributeCacheTest() {}
28
29 PrivetFileSystemAttributeCache cache_;
30 };
31
32 TEST_F(PrivetFileSystemAttributeCacheTest, AllAdded) {
33 scoped_ptr<base::Value> json(base::JSONReader::Read(kPrivetStorageJSON));
34 const base::DictionaryValue* dictionary_json;
35 json->GetAsDictionary(&dictionary_json);
36
37 cache_.AddFileInfoFromJSON(
38 base::FilePath(FILE_PATH_LITERAL("/test/path/foo")), dictionary_json);
39
40 const base::File::Info* info_foo =
41 cache_.GetFileInfo(base::FilePath(FILE_PATH_LITERAL("/test/path/foo")));
42 EXPECT_TRUE(info_foo->is_directory);
43 EXPECT_FALSE(info_foo->is_symbolic_link);
44
45 const base::File::Info* info_bar = cache_.GetFileInfo(
46 base::FilePath(FILE_PATH_LITERAL("/test/path/foo/bar")));
47 EXPECT_TRUE(info_bar->is_directory);
48 EXPECT_FALSE(info_bar->is_symbolic_link);
49
50 const base::File::Info* info_baz = cache_.GetFileInfo(
51 base::FilePath(FILE_PATH_LITERAL("/test/path/foo/baz.txt")));
52 EXPECT_FALSE(info_baz->is_directory);
53 EXPECT_FALSE(info_baz->is_symbolic_link);
54 EXPECT_EQ(12345, info_baz->size);
55
56 const base::File::Info* info_notfound = cache_.GetFileInfo(
57 base::FilePath(FILE_PATH_LITERAL("/test/path/foo/notfound.txt")));
58 EXPECT_EQ(NULL, info_notfound);
59 }
60
61 } // namespace
62
63 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698