| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "sync/api/sync_error.h" | 5 #include "components/sync/api/sync_error.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace syncer { | 12 namespace syncer { |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 TEST_F(SyncErrorTest, LowSeverity) { | 38 TEST_F(SyncErrorTest, LowSeverity) { |
| 39 tracked_objects::Location location = FROM_HERE; | 39 tracked_objects::Location location = FROM_HERE; |
| 40 std::string msg = "test"; | 40 std::string msg = "test"; |
| 41 ModelType type = PREFERENCES; | 41 ModelType type = PREFERENCES; |
| 42 SyncError error(location, SyncError::DATATYPE_POLICY_ERROR, msg, type); | 42 SyncError error(location, SyncError::DATATYPE_POLICY_ERROR, msg, type); |
| 43 ASSERT_TRUE(error.IsSet()); | 43 ASSERT_TRUE(error.IsSet()); |
| 44 EXPECT_EQ(location.line_number(), error.location().line_number()); | 44 EXPECT_EQ(location.line_number(), error.location().line_number()); |
| 45 EXPECT_EQ("disabled due to configuration constraints: ", | 45 EXPECT_EQ("disabled due to configuration constraints: ", |
| 46 error.GetMessagePrefix()); | 46 error.GetMessagePrefix()); |
| 47 EXPECT_EQ(msg, error.message()); | 47 EXPECT_EQ(msg, error.message()); |
| 48 EXPECT_EQ(type, error.model_type()); | 48 EXPECT_EQ(type, error.model_type()); |
| 49 EXPECT_EQ(SyncError::SYNC_ERROR_SEVERITY_INFO, error.GetSeverity()); | 49 EXPECT_EQ(SyncError::SYNC_ERROR_SEVERITY_INFO, error.GetSeverity()); |
| 50 } | 50 } |
| 51 | 51 |
| 52 TEST_F(SyncErrorTest, Reset) { | 52 TEST_F(SyncErrorTest, Reset) { |
| 53 tracked_objects::Location location = FROM_HERE; | 53 tracked_objects::Location location = FROM_HERE; |
| 54 std::string msg = "test"; | 54 std::string msg = "test"; |
| 55 ModelType type = PREFERENCES; | 55 ModelType type = PREFERENCES; |
| 56 | 56 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 error2 = SyncError(); | 127 error2 = SyncError(); |
| 128 EXPECT_FALSE(error2.IsSet()); | 128 EXPECT_FALSE(error2.IsSet()); |
| 129 } | 129 } |
| 130 | 130 |
| 131 TEST_F(SyncErrorTest, ToString) { | 131 TEST_F(SyncErrorTest, ToString) { |
| 132 tracked_objects::Location location = FROM_HERE; | 132 tracked_objects::Location location = FROM_HERE; |
| 133 std::string msg = "test"; | 133 std::string msg = "test"; |
| 134 ModelType type = PREFERENCES; | 134 ModelType type = PREFERENCES; |
| 135 std::string expected = std::string(ModelTypeToString(type)) + | 135 std::string expected = std::string(ModelTypeToString(type)) + |
| 136 " datatype error was encountered: " + msg; | 136 " datatype error was encountered: " + msg; |
| 137 LOG(INFO) << "Expect " << expected; | 137 LOG(INFO) << "Expect " << expected; |
| 138 SyncError error(location, SyncError::DATATYPE_ERROR, msg, type); | 138 SyncError error(location, SyncError::DATATYPE_ERROR, msg, type); |
| 139 EXPECT_TRUE(error.IsSet()); | 139 EXPECT_TRUE(error.IsSet()); |
| 140 EXPECT_NE(string::npos, error.ToString().find(expected)); | 140 EXPECT_NE(string::npos, error.ToString().find(expected)); |
| 141 | 141 |
| 142 SyncError error2; | 142 SyncError error2; |
| 143 EXPECT_FALSE(error2.IsSet()); | 143 EXPECT_FALSE(error2.IsSet()); |
| 144 EXPECT_EQ(std::string(), error2.ToString()); | 144 EXPECT_EQ(std::string(), error2.ToString()); |
| 145 | 145 |
| 146 error2 = error; | 146 error2 = error; |
| 147 EXPECT_TRUE(error2.IsSet()); | 147 EXPECT_TRUE(error2.IsSet()); |
| 148 EXPECT_NE(string::npos, error.ToString().find(expected)); | 148 EXPECT_NE(string::npos, error.ToString().find(expected)); |
| 149 } | 149 } |
| 150 | 150 |
| 151 } // namespace | 151 } // namespace |
| 152 | 152 |
| 153 } // namespace syncer | 153 } // namespace syncer |
| OLD | NEW |