Index: chrome/browser/bookmarks/bookmark_codec_unittest.cc |
diff --git a/chrome/browser/bookmarks/bookmark_codec_unittest.cc b/chrome/browser/bookmarks/bookmark_codec_unittest.cc |
index 09b9bd43bcd4d1e2d04e591199aebd32e64e81a3..9dc0e35792f2cecb9407879caf7cc6b50d95bbf8 100644 |
--- a/chrome/browser/bookmarks/bookmark_codec_unittest.cc |
+++ b/chrome/browser/bookmarks/bookmark_codec_unittest.cc |
@@ -2,6 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include "base/command_line.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/string_util.h" |
#include "base/utf_string_conversions.h" |
@@ -10,6 +11,7 @@ |
#include "chrome/browser/bookmarks/bookmark_model.h" |
#include "chrome/browser/bookmarks/bookmark_model_test_utils.h" |
#include "chrome/browser/bookmarks/bookmark_utils.h" |
+#include "chrome/common/chrome_switches.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace { |
@@ -111,6 +113,7 @@ class BookmarkCodecTest : public testing::Test { |
int64 max_id; |
bool result = codec->Decode(AsMutable(model->GetBookmarkBarNode()), |
AsMutable(model->other_node()), |
+ AsMutable(model->synced_node()), |
&max_id, value); |
model->set_next_node_id(max_id); |
return result; |
@@ -161,6 +164,7 @@ class BookmarkCodecTest : public testing::Test { |
std::set<int64> assigned_ids; |
CheckIDs(model->GetBookmarkBarNode(), &assigned_ids); |
CheckIDs(model->other_node(), &assigned_ids); |
+ CheckIDs(model->synced_node(), &assigned_ids); |
} |
}; |
@@ -287,3 +291,26 @@ TEST_F(BookmarkCodecTest, PersistIDsTest) { |
&decoded_model2, |
true); |
} |
+ |
+TEST_F(BookmarkCodecTest, CanDecodeModelWithoutSyncedBookmarks) { |
sky
2011/05/12 16:29:13
I assume we aren't going to have the switch foreve
|
+ scoped_ptr<BookmarkModel> model_to_encode(CreateTestModel3()); |
+ BookmarkCodec encoder; |
+ scoped_ptr<Value> model_value(encoder.Encode(model_to_encode.get())); |
+ |
+ // New model will be created with synced bookmarks. |
+ CommandLine::ForCurrentProcess()->AppendSwitch( |
+ switches::kEnableSyncedBookmarksFolder); |
+ |
+ BookmarkModel decoded_model(NULL); |
+ BookmarkCodec decoder; |
+ ASSERT_TRUE(Decode(&decoder, &decoded_model, *model_value.get())); |
+ BookmarkModelTestUtils::AssertNodesEqual( |
+ model_to_encode->GetBookmarkBarNode(), |
+ decoded_model.GetBookmarkBarNode(), |
+ false); |
+ BookmarkModelTestUtils::AssertNodesEqual(model_to_encode->other_node(), |
+ decoded_model.other_node(), |
+ false); |
+ // Note: Explicitly don't check synced_node since it's not present in the old |
+ // model. |
+} |