OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/json/json_file_value_serializer.h" | 7 #include "base/json/json_file_value_serializer.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 BookmarkModelTestUtils::AssertModelsEqual(&decoded_model, | 293 BookmarkModelTestUtils::AssertModelsEqual(&decoded_model, |
294 &decoded_model2, | 294 &decoded_model2, |
295 true); | 295 true); |
296 } | 296 } |
297 | 297 |
298 TEST_F(BookmarkCodecTest, CanDecodeModelWithoutMobileBookmarks) { | 298 TEST_F(BookmarkCodecTest, CanDecodeModelWithoutMobileBookmarks) { |
299 base::FilePath test_data_directory; | 299 base::FilePath test_data_directory; |
300 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory)); | 300 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory)); |
301 base::FilePath test_file = test_data_directory.AppendASCII( | 301 base::FilePath test_file = test_data_directory.AppendASCII( |
302 "bookmarks/model_without_sync.json"); | 302 "bookmarks/model_without_sync.json"); |
303 ASSERT_TRUE(file_util::PathExists(test_file)); | 303 ASSERT_TRUE(base::PathExists(test_file)); |
304 | 304 |
305 JSONFileValueSerializer serializer(test_file); | 305 JSONFileValueSerializer serializer(test_file); |
306 scoped_ptr<Value> root(serializer.Deserialize(NULL, NULL)); | 306 scoped_ptr<Value> root(serializer.Deserialize(NULL, NULL)); |
307 | 307 |
308 BookmarkModel decoded_model(NULL); | 308 BookmarkModel decoded_model(NULL); |
309 BookmarkCodec decoder; | 309 BookmarkCodec decoder; |
310 ASSERT_TRUE(Decode(&decoder, &decoded_model, *root.get())); | 310 ASSERT_TRUE(Decode(&decoder, &decoded_model, *root.get())); |
311 ExpectIDsUnique(&decoded_model); | 311 ExpectIDsUnique(&decoded_model); |
312 | 312 |
313 const BookmarkNode* bbn = decoded_model.bookmark_bar_node(); | 313 const BookmarkNode* bbn = decoded_model.bookmark_bar_node(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 EXPECT_TRUE(model->root_node()->GetMetaInfo("model_info", &meta_value)); | 353 EXPECT_TRUE(model->root_node()->GetMetaInfo("model_info", &meta_value)); |
354 EXPECT_EQ("value1", meta_value); | 354 EXPECT_EQ("value1", meta_value); |
355 EXPECT_FALSE(model->root_node()->GetMetaInfo("other_key", &meta_value)); | 355 EXPECT_FALSE(model->root_node()->GetMetaInfo("other_key", &meta_value)); |
356 const BookmarkNode* bbn = model->bookmark_bar_node(); | 356 const BookmarkNode* bbn = model->bookmark_bar_node(); |
357 ASSERT_EQ(1, bbn->child_count()); | 357 ASSERT_EQ(1, bbn->child_count()); |
358 const BookmarkNode* child = bbn->GetChild(0); | 358 const BookmarkNode* child = bbn->GetChild(0); |
359 EXPECT_TRUE(child->GetMetaInfo("node_info", &meta_value)); | 359 EXPECT_TRUE(child->GetMetaInfo("node_info", &meta_value)); |
360 EXPECT_EQ("value2", meta_value); | 360 EXPECT_EQ("value2", meta_value); |
361 EXPECT_FALSE(child->GetMetaInfo("other_key", &meta_value)); | 361 EXPECT_FALSE(child->GetMetaInfo("other_key", &meta_value)); |
362 } | 362 } |
OLD | NEW |