Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/utility/importer/bookmarks_file_importer.h" | 5 #include "chrome/utility/importer/bookmarks_file_importer.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 | 9 |
| 10 namespace bookmark_html_reader { | |
| 11 | |
| 12 bool CanImportURLAsSearchEngine(const GURL& url, base::string16* decoded_url); | |
| 13 | |
| 14 } // namespace namespace bookmark_html_reader | |
|
Ilya Sherman
2014/09/30 20:54:13
nit: Why is this needed? Can you #include the app
Tapu Ghose
2014/10/07 02:02:44
Removed.
| |
| 15 | |
| 10 namespace internal { | 16 namespace internal { |
| 11 | 17 |
| 12 bool CanImportURL(const GURL& url); | 18 bool CanImportURL(const GURL& url); |
| 13 | 19 |
| 14 } // namespace internal | 20 } // namespace internal |
| 15 | 21 |
| 22 | |
|
Ilya Sherman
2014/09/30 20:54:12
nit: Please revert this diff.
Tapu Ghose
2014/10/07 02:02:44
Done.
| |
| 16 TEST(BookmarksFileImporterTest, CanImportURL) { | 23 TEST(BookmarksFileImporterTest, CanImportURL) { |
| 17 struct TestCase { | 24 struct TestCase { |
| 18 const std::string url; | 25 const std::string url; |
| 19 const bool can_be_imported; | 26 const bool can_be_imported; |
| 20 } test_cases[] = { | 27 } test_cases[] = { |
| 21 { "http://www.example.com", true }, | 28 { "http://www.example.com", true }, |
| 22 { "https://www.example.com", true }, | 29 { "https://www.example.com", true }, |
| 23 { "ftp://www.example.com", true }, | 30 { "ftp://www.example.com", true }, |
| 24 { "aim:GoIm?screenname=myscreenname&message=hello", true }, | 31 { "aim:GoIm?screenname=myscreenname&message=hello", true }, |
| 25 { "chrome://version", true }, | 32 { "chrome://version", true }, |
| 26 { "chrome://chrome-urls", true }, | 33 { "chrome://chrome-urls", true }, |
| 27 { "chrome://kill", true }, | 34 { "chrome://kill", true }, |
| 28 { "chrome://chrome", true }, | 35 { "chrome://chrome", true }, |
| 29 { "chrome://about", true }, | 36 { "chrome://about", true }, |
| 30 { "about:version", true }, | 37 { "about:version", true }, |
| 31 { "about:blank", true }, | 38 { "about:blank", true }, |
| 32 { "about:credits", true }, | 39 { "about:credits", true }, |
| 33 { "wyciwyg://example.com", false }, | 40 { "wyciwyg://example.com", false }, |
| 34 { "place://google.com", false }, | 41 { "place://google.com", false }, |
| 35 { "about:config", false }, | 42 { "about:config", false }, |
| 36 { "about:moon", false }, | 43 { "about:moon", false }, |
| 37 }; | 44 }; |
| 38 | 45 |
| 39 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 46 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { |
| 40 EXPECT_EQ(test_cases[i].can_be_imported, | 47 EXPECT_EQ(test_cases[i].can_be_imported, |
| 41 internal::CanImportURL(GURL(test_cases[i].url))); | 48 internal::CanImportURL(GURL(test_cases[i].url))); |
|
Ilya Sherman
2014/09/30 20:54:12
nit: Please revert this diff.
Tapu Ghose
2014/10/07 02:02:44
Done.
| |
| 42 } | 49 } |
| 43 } | 50 } |
| 51 | |
| 52 TEST(BookmarksFileImporterTest, CanImportURLAsSearchEngine) { | |
| 53 struct TestCase { | |
| 54 const std::string url; | |
| 55 const bool can_be_imported_as_search_engine; | |
| 56 } test_cases[] = { | |
| 57 { "http://www.example.%s.com", true }, | |
| 58 { "wyciwyg://example.%s.com", false }, | |
| 59 }; | |
| 60 | |
| 61 base::string16 decoded_url; | |
| 62 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | |
| 63 EXPECT_EQ(test_cases[i].can_be_imported_as_search_engine, | |
| 64 bookmark_html_reader::CanImportURLAsSearchEngine( | |
| 65 GURL(test_cases[i].url), &decoded_url)); | |
| 66 } | |
|
Ilya Sherman
2014/09/30 20:54:13
This test code belongs in the bookmark_html_reader
Tapu Ghose
2014/10/07 02:02:44
Removed. Corresponding test code is added to bookm
| |
| 67 } | |
| OLD | NEW |