OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/sync/chrome_sync_client.h" | 5 #include "chrome/browser/sync/chrome_sync_client.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include <memory> |
| 8 |
8 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
9 #include "components/sync_driver/sync_api_component_factory.h" | 10 #include "components/sync_driver/sync_api_component_factory.h" |
10 #include "components/sync_sessions/sync_sessions_client.h" | 11 #include "components/sync_sessions/sync_sessions_client.h" |
11 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "url/gurl.h" | 14 #include "url/gurl.h" |
14 | 15 |
15 namespace browser_sync { | 16 namespace browser_sync { |
16 | 17 |
17 namespace { | 18 namespace { |
18 | 19 |
19 const std::string kValidUrl = "http://www.example.com"; | 20 const std::string kValidUrl = "http://www.example.com"; |
20 const std::string kInvalidUrl = "invalid.url"; | 21 const std::string kInvalidUrl = "invalid.url"; |
21 | 22 |
22 class ChromeSyncClientTest : public testing::Test { | 23 class ChromeSyncClientTest : public testing::Test { |
23 public: | 24 public: |
24 ChromeSyncClientTest() | 25 ChromeSyncClientTest() |
25 : sync_client_(new ChromeSyncClient(nullptr, nullptr)) {} | 26 : sync_client_(new ChromeSyncClient(nullptr, nullptr)) {} |
26 ~ChromeSyncClientTest() override {} | 27 ~ChromeSyncClientTest() override {} |
27 | 28 |
28 ChromeSyncClient* sync_client() { return sync_client_.get(); } | 29 ChromeSyncClient* sync_client() { return sync_client_.get(); } |
29 | 30 |
30 private: | 31 private: |
31 content::TestBrowserThreadBundle thread_bundle_; | 32 content::TestBrowserThreadBundle thread_bundle_; |
32 scoped_ptr<ChromeSyncClient> sync_client_; | 33 std::unique_ptr<ChromeSyncClient> sync_client_; |
33 }; | 34 }; |
34 | 35 |
35 TEST_F(ChromeSyncClientTest, ShouldSyncURL) { | 36 TEST_F(ChromeSyncClientTest, ShouldSyncURL) { |
36 EXPECT_TRUE( | 37 EXPECT_TRUE( |
37 sync_client()->GetSyncSessionsClient()->ShouldSyncURL(GURL(kValidUrl))); | 38 sync_client()->GetSyncSessionsClient()->ShouldSyncURL(GURL(kValidUrl))); |
38 EXPECT_TRUE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( | 39 EXPECT_TRUE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( |
39 GURL("other://anything"))); | 40 GURL("other://anything"))); |
40 EXPECT_TRUE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( | 41 EXPECT_TRUE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( |
41 GURL("chrome-other://anything"))); | 42 GURL("chrome-other://anything"))); |
42 | 43 |
43 EXPECT_FALSE( | 44 EXPECT_FALSE( |
44 sync_client()->GetSyncSessionsClient()->ShouldSyncURL(GURL(kInvalidUrl))); | 45 sync_client()->GetSyncSessionsClient()->ShouldSyncURL(GURL(kInvalidUrl))); |
45 EXPECT_FALSE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( | 46 EXPECT_FALSE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( |
46 GURL("file://anything"))); | 47 GURL("file://anything"))); |
47 EXPECT_FALSE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( | 48 EXPECT_FALSE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( |
48 GURL("chrome://anything"))); | 49 GURL("chrome://anything"))); |
49 EXPECT_FALSE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( | 50 EXPECT_FALSE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( |
50 GURL("chrome-native://anything"))); | 51 GURL("chrome-native://anything"))); |
51 | 52 |
52 EXPECT_TRUE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( | 53 EXPECT_TRUE(sync_client()->GetSyncSessionsClient()->ShouldSyncURL( |
53 GURL(chrome::kChromeUIHistoryURL))); | 54 GURL(chrome::kChromeUIHistoryURL))); |
54 } | 55 } |
55 | 56 |
56 } // namespace | 57 } // namespace |
57 | 58 |
58 } // namespace browser_sync | 59 } // namespace browser_sync |
OLD | NEW |