Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / chrome / browser / local_discovery / storage / privet_filesystem_attribute_cache_unittest.cc
blob30c660cc6c7b49cbf8a4ad7b1e51c7497b5ec084
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.
5 #include "base/files/file_path.h"
6 #include "base/json/json_reader.h"
7 #include "chrome/browser/local_discovery/storage/privet_filesystem_attribute_cache.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 namespace local_discovery {
12 namespace {
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 " ]}";
23 class PrivetFileSystemAttributeCacheTest : public ::testing::Test {
24 public:
25 PrivetFileSystemAttributeCacheTest() {}
27 virtual ~PrivetFileSystemAttributeCacheTest() {}
29 PrivetFileSystemAttributeCache cache_;
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);
37 cache_.AddFileInfoFromJSON(
38 base::FilePath(FILE_PATH_LITERAL("/test/path/foo")), dictionary_json);
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);
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);
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);
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);
61 } // namespace
63 } // namespace local_discovery