Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / sync / about_sync_util_unittest.cc
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
3 // found in the LICENSE file.
4
5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/browser/profiles/profile.h"
7 #include "chrome/browser/sync/about_sync_util.h"
8 #include "chrome/browser/sync/profile_sync_service_mock.h"
9 #include "content/public/test/test_browser_thread_bundle.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 using ::testing::NiceMock;
14 using ::testing::Return;
15 using ::testing::_;
16
17 namespace sync_ui_util {
18 namespace {
19
20 TEST(SyncUIUtilTestAbout, ConstructAboutInformationWithUnrecoverableErrorTest) {
21   content::TestBrowserThreadBundle thread_bundle(
22       content::TestBrowserThreadBundle::DEFAULT);
23   scoped_ptr<Profile> profile(
24       ProfileSyncServiceMock::MakeSignedInTestingProfile());
25   NiceMock<ProfileSyncServiceMock> service(profile.get());
26
27   // Will be released when the dictionary is destroyed
28   base::string16 str(base::ASCIIToUTF16("none"));
29
30   browser_sync::SyncBackendHost::Status status;
31
32   EXPECT_CALL(service, HasSyncSetupCompleted())
33               .WillOnce(Return(true));
34   EXPECT_CALL(service, QueryDetailedSyncStatus(_))
35               .WillOnce(Return(false));
36   EXPECT_CALL(service, GetLastSessionSnapshot())
37       .WillOnce(Return(syncer::sessions::SyncSessionSnapshot()));
38   EXPECT_CALL(service, HasUnrecoverableError()).WillRepeatedly(Return(true));
39
40   EXPECT_CALL(service, GetLastSyncedTimeString())
41               .WillOnce(Return(str));
42
43   scoped_ptr<base::DictionaryValue> strings(
44       ConstructAboutInformation(&service));
45
46   EXPECT_TRUE(strings->HasKey("unrecoverable_error_detected"));
47 }
48
49 } // namespace
50 } // namespace sync_ui_util