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 "testing/gtest/include/gtest/gtest.h" |
| 10 |
| 11 using std::string; |
| 12 using syncable::ModelType; |
| 13 |
| 14 namespace { |
| 15 |
| 16 typedef testing::Test SyncErrorTest; |
| 17 |
| 18 TEST_F(SyncErrorTest, Unset) { |
| 19 SyncError error; |
| 20 EXPECT_FALSE(error.IsInitialized()); |
| 21 } |
| 22 |
| 23 TEST_F(SyncErrorTest, Default) { |
| 24 tracked_objects::Location location = FROM_HERE; |
| 25 std::string msg = "test"; |
| 26 ModelType type = syncable::PREFERENCES; |
| 27 SyncError error(location, msg, type); |
| 28 EXPECT_TRUE(error.IsInitialized()); |
| 29 EXPECT_EQ(location.line_number(), error.location().line_number()); |
| 30 EXPECT_EQ(msg, error.message()); |
| 31 EXPECT_EQ(type, error.type()); |
| 32 } |
| 33 |
| 34 TEST_F(SyncErrorTest, Reset) { |
| 35 tracked_objects::Location location = FROM_HERE; |
| 36 std::string msg = "test"; |
| 37 ModelType type = syncable::PREFERENCES; |
| 38 |
| 39 SyncError error; |
| 40 EXPECT_FALSE(error.IsInitialized()); |
| 41 |
| 42 error.reset(location, msg, type); |
| 43 EXPECT_TRUE(error.IsInitialized()); |
| 44 EXPECT_EQ(location.line_number(), error.location().line_number()); |
| 45 EXPECT_EQ(msg, error.message()); |
| 46 EXPECT_EQ(type, error.type()); |
| 47 |
| 48 tracked_objects::Location location2 = FROM_HERE; |
| 49 std::string msg2 = "test"; |
| 50 ModelType type2 = syncable::PREFERENCES; |
| 51 error.reset(location2, msg2, type2); |
| 52 EXPECT_TRUE(error.IsInitialized()); |
| 53 EXPECT_EQ(location2.line_number(), error.location().line_number()); |
| 54 EXPECT_EQ(msg2, error.message()); |
| 55 EXPECT_EQ(type2, error.type()); |
| 56 } |
| 57 |
| 58 TEST_F(SyncErrorTest, Copy) { |
| 59 tracked_objects::Location location = FROM_HERE; |
| 60 std::string msg = "test"; |
| 61 ModelType type = syncable::PREFERENCES; |
| 62 |
| 63 SyncError error1(location, msg, type); |
| 64 EXPECT_TRUE(error1.IsInitialized()); |
| 65 EXPECT_EQ(location.line_number(), error1.location().line_number()); |
| 66 EXPECT_EQ(msg, error1.message()); |
| 67 EXPECT_EQ(type, error1.type()); |
| 68 |
| 69 SyncError error2(error1); |
| 70 EXPECT_TRUE(error2.IsInitialized()); |
| 71 EXPECT_EQ(error1.location().line_number(), error2.location().line_number()); |
| 72 EXPECT_EQ(error1.message(), error2.message()); |
| 73 EXPECT_EQ(error1.type(), error2.type()); |
| 74 } |
| 75 |
| 76 } // namespace |
OLD | NEW |