Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6930)

Unified Diff: chrome/browser/sync/api/sync_error_unittest.cc

Issue 7453014: [Sync] Refactor sync datatype error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Really fix compile Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sync/api/sync_error_unittest.cc
diff --git a/chrome/browser/sync/api/sync_error_unittest.cc b/chrome/browser/sync/api/sync_error_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fee1e1255def33f7b9067ced2bc26a62a6339f2f
--- /dev/null
+++ b/chrome/browser/sync/api/sync_error_unittest.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/api/sync_error.h"
+
+#include <string>
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+using std::string;
+using syncable::ModelType;
+
+namespace {
+
+typedef testing::Test SyncErrorTest;
+
+TEST_F(SyncErrorTest, Unset) {
+ SyncError error;
+ EXPECT_FALSE(error.is_set());
+}
+
+TEST_F(SyncErrorTest, Default) {
+ tracked_objects::Location location = FROM_HERE;
+ std::string msg = "test";
+ ModelType type = syncable::PREFERENCES;
+ SyncError error(location, msg, type);
+ EXPECT_TRUE(error.is_set());
+ EXPECT_EQ(location.line_number(), error.location().line_number());
+ EXPECT_EQ(msg, error.message());
+ EXPECT_EQ(type, error.type());
+}
+
+TEST_F(SyncErrorTest, Reset) {
+ tracked_objects::Location location = FROM_HERE;
+ std::string msg = "test";
+ ModelType type = syncable::PREFERENCES;
+
+ SyncError error;
+ EXPECT_FALSE(error.is_set());
+
+ error.reset(location, msg, type);
+ EXPECT_TRUE(error.is_set());
+ EXPECT_EQ(location.line_number(), error.location().line_number());
+ EXPECT_EQ(msg, error.message());
+ EXPECT_EQ(type, error.type());
+
+ tracked_objects::Location location2 = FROM_HERE;
+ std::string msg2 = "test";
+ ModelType type2 = syncable::PREFERENCES;
+ error.reset(location2, msg2, type2);
+ EXPECT_TRUE(error.is_set());
+ EXPECT_EQ(location2.line_number(), error.location().line_number());
+ EXPECT_EQ(msg2, error.message());
+ EXPECT_EQ(type2, error.type());
+}
+
+TEST_F(SyncErrorTest, Copy) {
+ tracked_objects::Location location = FROM_HERE;
+ std::string msg = "test";
+ ModelType type = syncable::PREFERENCES;
+
+ SyncError error1(location, msg, type);
+ EXPECT_TRUE(error1.is_set());
+ EXPECT_EQ(location.line_number(), error1.location().line_number());
+ EXPECT_EQ(msg, error1.message());
+ EXPECT_EQ(type, error1.type());
+
+ SyncError error2(error1);
+ EXPECT_TRUE(error2.is_set());
+ EXPECT_EQ(error1.location().line_number(), error2.location().line_number());
+ EXPECT_EQ(error1.message(), error2.message());
+ EXPECT_EQ(error1.type(), error2.type());
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698