OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 using base::ExpectDictBooleanValue; | 44 using base::ExpectDictBooleanValue; |
45 using base::ExpectDictStringValue; | 45 using base::ExpectDictStringValue; |
46 | 46 |
47 class SyncableKernelTest : public testing::Test {}; | 47 class SyncableKernelTest : public testing::Test {}; |
48 | 48 |
49 // TODO(akalin): Add unit tests for EntryKernel::ContainsString(). | 49 // TODO(akalin): Add unit tests for EntryKernel::ContainsString(). |
50 | 50 |
51 TEST_F(SyncableKernelTest, ToValue) { | 51 TEST_F(SyncableKernelTest, ToValue) { |
52 EntryKernel kernel; | 52 EntryKernel kernel; |
53 scoped_ptr<DictionaryValue> value(kernel.ToValue(NULL)); | 53 scoped_ptr<base::DictionaryValue> value(kernel.ToValue(NULL)); |
54 if (value) { | 54 if (value) { |
55 // Not much to check without repeating the ToValue() code. | 55 // Not much to check without repeating the ToValue() code. |
56 EXPECT_TRUE(value->HasKey("isDirty")); | 56 EXPECT_TRUE(value->HasKey("isDirty")); |
57 // The extra +2 is for "isDirty" and "serverModelType". | 57 // The extra +2 is for "isDirty" and "serverModelType". |
58 EXPECT_EQ(BIT_TEMPS_END - BEGIN_FIELDS + 2, | 58 EXPECT_EQ(BIT_TEMPS_END - BEGIN_FIELDS + 2, |
59 static_cast<int>(value->size())); | 59 static_cast<int>(value->size())); |
60 } else { | 60 } else { |
61 ADD_FAILURE(); | 61 ADD_FAILURE(); |
62 } | 62 } |
63 } | 63 } |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 NULL); | 385 NULL); |
386 ASSERT_EQ(OPENED, dir.Open( | 386 ASSERT_EQ(OPENED, dir.Open( |
387 "SimpleTest", &delegate_, NullTransactionObserver())); | 387 "SimpleTest", &delegate_, NullTransactionObserver())); |
388 | 388 |
389 const Id id = TestIdFactory::FromNumber(99); | 389 const Id id = TestIdFactory::FromNumber(99); |
390 { | 390 { |
391 ReadTransaction rtrans(FROM_HERE, &dir); | 391 ReadTransaction rtrans(FROM_HERE, &dir); |
392 Entry e(&rtrans, GET_BY_ID, id); | 392 Entry e(&rtrans, GET_BY_ID, id); |
393 EXPECT_FALSE(e.good()); // Hasn't been written yet. | 393 EXPECT_FALSE(e.good()); // Hasn't been written yet. |
394 | 394 |
395 scoped_ptr<DictionaryValue> value(e.ToValue(NULL)); | 395 scoped_ptr<base::DictionaryValue> value(e.ToValue(NULL)); |
396 ExpectDictBooleanValue(false, *value, "good"); | 396 ExpectDictBooleanValue(false, *value, "good"); |
397 EXPECT_EQ(1u, value->size()); | 397 EXPECT_EQ(1u, value->size()); |
398 } | 398 } |
399 | 399 |
400 // Test creating a new meta entry. | 400 // Test creating a new meta entry. |
401 { | 401 { |
402 WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); | 402 WriteTransaction wtrans(FROM_HERE, UNITTEST, &dir); |
403 MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "new"); | 403 MutableEntry me(&wtrans, CREATE, BOOKMARKS, wtrans.root_id(), "new"); |
404 ASSERT_TRUE(me.good()); | 404 ASSERT_TRUE(me.good()); |
405 me.Put(ID, id); | 405 me.Put(ID, id); |
406 me.Put(BASE_VERSION, 1); | 406 me.Put(BASE_VERSION, 1); |
407 | 407 |
408 scoped_ptr<DictionaryValue> value(me.ToValue(NULL)); | 408 scoped_ptr<base::DictionaryValue> value(me.ToValue(NULL)); |
409 ExpectDictBooleanValue(true, *value, "good"); | 409 ExpectDictBooleanValue(true, *value, "good"); |
410 EXPECT_TRUE(value->HasKey("kernel")); | 410 EXPECT_TRUE(value->HasKey("kernel")); |
411 ExpectDictStringValue("Bookmarks", *value, "modelType"); | 411 ExpectDictStringValue("Bookmarks", *value, "modelType"); |
412 ExpectDictBooleanValue(true, *value, "existsOnClientBecauseNameIsNonEmpty"); | 412 ExpectDictBooleanValue(true, *value, "existsOnClientBecauseNameIsNonEmpty"); |
413 ExpectDictBooleanValue(false, *value, "isRoot"); | 413 ExpectDictBooleanValue(false, *value, "isRoot"); |
414 } | 414 } |
415 | 415 |
416 dir.SaveChanges(); | 416 dir.SaveChanges(); |
417 } | 417 } |
418 | 418 |
(...skipping 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2294 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 2294 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
2295 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 2295 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
2296 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); | 2296 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); |
2297 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); | 2297 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); |
2298 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); | 2298 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); |
2299 } | 2299 } |
2300 | 2300 |
2301 } // namespace | 2301 } // namespace |
2302 } // namespace syncable | 2302 } // namespace syncable |
2303 } // namespace syncer | 2303 } // namespace syncer |
OLD | NEW |