summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sync/sync_ui_util_unittest.cc
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-15 20:54:24 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-15 20:54:24 +0000
commitf1e6e0218795cf635c877a60dbd5e8be784b381d (patch)
tree9b11d48476580205972516bc2765586ca280d002 /chrome/browser/sync/sync_ui_util_unittest.cc
parent9062e85d56308d06cfb0926b0eedee313283a44d (diff)
downloadchromium_src-f1e6e0218795cf635c877a60dbd5e8be784b381d.zip
chromium_src-f1e6e0218795cf635c877a60dbd5e8be784b381d.tar.gz
chromium_src-f1e6e0218795cf635c877a60dbd5e8be784b381d.tar.bz2
[Sync] fix about:sync crash with unrecoverable error
If the client had encountered an unrecoverable error typing about:sync would crash because the client code would try to dereference the backendhost for the purpose of printing the model group information(by this time backendhost would have been released). The fix is to bail out of printing the model information if the client had encountered an unrecoverable error. however we would still print the client had encountered an urecoverable error and the line number etc. In the process moved a bunch of code related to collecting about information for sync, from browser_about_handler.cc to sync_ui_util.cc. The refactoing helps us in unit testing by passing in a mock service object. BUG=55503 TEST=Wrote a new unit test for it. ConstructAboutInformationWithUnrecoverableErrorTest. Also tested by pretending one of the datatypes generated an unrecoverable error in the debugger. Original patch by lipalani@google.com Original review: http://codereview.chromium.org/3715002 Review URL: http://codereview.chromium.org/3810011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync/sync_ui_util_unittest.cc')
-rw-r--r--chrome/browser/sync/sync_ui_util_unittest.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/chrome/browser/sync/sync_ui_util_unittest.cc b/chrome/browser/sync/sync_ui_util_unittest.cc
new file mode 100644
index 0000000..7122170
--- /dev/null
+++ b/chrome/browser/sync/sync_ui_util_unittest.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2010 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 "base/basictypes.h"
+#include "chrome/browser/sync/sync_ui_util.h"
+#include "chrome/browser/sync/profile_sync_service_mock.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gmock/include/gmock/gmock-actions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::testing::Return;
+using ::testing::NiceMock;
+TEST(SyncUIUtilTest, ConstructAboutInformationWithUnrecoverableErrorTest) {
+ NiceMock<ProfileSyncServiceMock> service;
+ DictionaryValue strings;
+
+ // Will be released when the dictionary is destroyed
+ string16 str(ASCIIToUTF16("none"));
+
+ browser_sync::SyncBackendHost::Status status =
+ { browser_sync::SyncBackendHost::Status::OFFLINE_UNUSABLE };
+
+ EXPECT_CALL(service, HasSyncSetupCompleted())
+ .WillOnce(Return(true));
+ EXPECT_CALL(service, QueryDetailedSyncStatus())
+ .WillOnce(Return(status));
+
+ EXPECT_CALL(service, unrecoverable_error_detected())
+ .WillOnce(Return(true));
+
+ EXPECT_CALL(service, GetLastSyncedTimeString())
+ .WillOnce(Return(str));
+
+ sync_ui_util::ConstructAboutInformation(&service, &strings);
+
+ EXPECT_TRUE(strings.HasKey("unrecoverable_error_detected"));
+}
+