OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 "chrome/browser/sync/api/sync_error.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/tracked.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 |
| 12 using std::string; |
| 13 using syncable::ModelType; |
| 14 |
| 15 namespace { |
| 16 |
| 17 typedef testing::Test SyncErrorTest; |
| 18 |
| 19 TEST_F(SyncErrorTest, Unset) { |
| 20 SyncError error; |
| 21 EXPECT_FALSE(error.IsInitialized()); |
| 22 } |
| 23 |
| 24 TEST_F(SyncErrorTest, Default) { |
| 25 tracked_objects::Location location = FROM_HERE; |
| 26 std::string msg = "test"; |
| 27 ModelType type = syncable::PREFERENCES; |
| 28 SyncError error(location, msg, type); |
| 29 EXPECT_TRUE(error.IsInitialized()); |
| 30 EXPECT_EQ(location.line_number(), error.location().line_number()); |
| 31 EXPECT_EQ(msg, error.message()); |
| 32 EXPECT_EQ(type, error.type()); |
| 33 } |
| 34 |
| 35 TEST_F(SyncErrorTest, Reset) { |
| 36 tracked_objects::Location location = FROM_HERE; |
| 37 std::string msg = "test"; |
| 38 ModelType type = syncable::PREFERENCES; |
| 39 |
| 40 SyncError error; |
| 41 EXPECT_FALSE(error.IsInitialized()); |
| 42 |
| 43 error.Reset(location, msg, type); |
| 44 EXPECT_TRUE(error.IsInitialized()); |
| 45 EXPECT_EQ(location.line_number(), error.location().line_number()); |
| 46 EXPECT_EQ(msg, error.message()); |
| 47 EXPECT_EQ(type, error.type()); |
| 48 |
| 49 tracked_objects::Location location2 = FROM_HERE; |
| 50 std::string msg2 = "test"; |
| 51 ModelType type2 = syncable::PREFERENCES; |
| 52 error.Reset(location2, msg2, type2); |
| 53 EXPECT_TRUE(error.IsInitialized()); |
| 54 EXPECT_EQ(location2.line_number(), error.location().line_number()); |
| 55 EXPECT_EQ(msg2, error.message()); |
| 56 EXPECT_EQ(type2, error.type()); |
| 57 } |
| 58 |
| 59 TEST_F(SyncErrorTest, Copy) { |
| 60 tracked_objects::Location location = FROM_HERE; |
| 61 std::string msg = "test"; |
| 62 ModelType type = syncable::PREFERENCES; |
| 63 |
| 64 SyncError error1(location, msg, type); |
| 65 EXPECT_TRUE(error1.IsInitialized()); |
| 66 EXPECT_EQ(location.line_number(), error1.location().line_number()); |
| 67 EXPECT_EQ(msg, error1.message()); |
| 68 EXPECT_EQ(type, error1.type()); |
| 69 |
| 70 SyncError error2(error1); |
| 71 EXPECT_TRUE(error2.IsInitialized()); |
| 72 EXPECT_EQ(error1.location().line_number(), error2.location().line_number()); |
| 73 EXPECT_EQ(error1.message(), error2.message()); |
| 74 EXPECT_EQ(error1.type(), error2.type()); |
| 75 } |
| 76 |
| 77 TEST_F(SyncErrorTest, Assign) { |
| 78 tracked_objects::Location location = FROM_HERE; |
| 79 std::string msg = "test"; |
| 80 ModelType type = syncable::PREFERENCES; |
| 81 |
| 82 SyncError error1(location, msg, type); |
| 83 EXPECT_TRUE(error1.IsInitialized()); |
| 84 EXPECT_EQ(location.line_number(), error1.location().line_number()); |
| 85 EXPECT_EQ(msg, error1.message()); |
| 86 EXPECT_EQ(type, error1.type()); |
| 87 |
| 88 SyncError error2; |
| 89 error2 = error1; |
| 90 EXPECT_TRUE(error2.IsInitialized()); |
| 91 EXPECT_EQ(error1.location().line_number(), error2.location().line_number()); |
| 92 EXPECT_EQ(error1.message(), error2.message()); |
| 93 EXPECT_EQ(error1.type(), error2.type()); |
| 94 } |
| 95 |
| 96 } // namespace |
OLD | NEW |