Home | History | Annotate | Download | only in api
      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
      3 // found in the LICENSE file.
      4 
      5 #include "sync/api/sync_merge_result.h"
      6 
      7 #include "base/location.h"
      8 #include "testing/gtest/include/gtest/gtest.h"
      9 
     10 namespace syncer {
     11 
     12 namespace {
     13 
     14 typedef testing::Test SyncMergeResultTest;
     15 
     16 TEST_F(SyncMergeResultTest, Unset) {
     17   SyncMergeResult merge_result(BOOKMARKS);
     18   EXPECT_FALSE(merge_result.error().IsSet());
     19   EXPECT_EQ(0, merge_result.num_items_before_association());
     20   EXPECT_EQ(0, merge_result.num_items_after_association());
     21   EXPECT_EQ(0, merge_result.num_items_added());
     22   EXPECT_EQ(0, merge_result.num_items_deleted());
     23   EXPECT_EQ(0, merge_result.num_items_modified());
     24 }
     25 
     26 TEST_F(SyncMergeResultTest, SetError) {
     27   SyncError error(FROM_HERE, SyncError::DATATYPE_ERROR, "message", BOOKMARKS);
     28   SyncMergeResult merge_result(BOOKMARKS);
     29 
     30   merge_result.set_error(error);
     31   EXPECT_TRUE(merge_result.error().IsSet());
     32   EXPECT_EQ(BOOKMARKS, merge_result.model_type());
     33 }
     34 
     35 TEST_F(SyncMergeResultTest, SetNumItemsBeforeAssociation) {
     36   SyncMergeResult merge_result(BOOKMARKS);
     37   EXPECT_EQ(0, merge_result.num_items_before_association());
     38 
     39   merge_result.set_num_items_before_association(10);
     40   EXPECT_EQ(10, merge_result.num_items_before_association());
     41 }
     42 
     43 TEST_F(SyncMergeResultTest, SetNumItemsAfterAssociation) {
     44   SyncMergeResult merge_result(BOOKMARKS);
     45   EXPECT_EQ(0, merge_result.num_items_after_association());
     46 
     47   merge_result.set_num_items_after_association(10);
     48   EXPECT_EQ(10, merge_result.num_items_after_association());
     49 }
     50 
     51 TEST_F(SyncMergeResultTest, SetNumItemsAdded) {
     52   SyncMergeResult merge_result(BOOKMARKS);
     53   EXPECT_EQ(0, merge_result.num_items_added());
     54 
     55   merge_result.set_num_items_added(10);
     56   EXPECT_EQ(10, merge_result.num_items_added());
     57 }
     58 
     59 TEST_F(SyncMergeResultTest, SetNumItemsDeleted) {
     60   SyncMergeResult merge_result(BOOKMARKS);
     61   EXPECT_EQ(0, merge_result.num_items_deleted());
     62 
     63   merge_result.set_num_items_deleted(10);
     64   EXPECT_EQ(10, merge_result.num_items_deleted());
     65 }
     66 
     67 TEST_F(SyncMergeResultTest, SetNumItemsModified) {
     68   SyncMergeResult merge_result(BOOKMARKS);
     69   EXPECT_EQ(0, merge_result.num_items_modified());
     70 
     71   merge_result.set_num_items_modified(10);
     72   EXPECT_EQ(10, merge_result.num_items_modified());
     73 }
     74 
     75 }  // namespace
     76 
     77 }  // namespace syncer
     78