| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/bookmarks/imported_bookmark_entry.h" |
| 13 #include "chrome/browser/first_run/first_run.h" | 14 #include "chrome/browser/first_run/first_run.h" |
| 14 #include "chrome/browser/first_run/first_run_internal.h" | 15 #include "chrome/browser/first_run/first_run_internal.h" |
| 15 #include "chrome/browser/importer/toolbar_importer.h" | 16 #include "chrome/browser/importer/toolbar_importer.h" |
| 16 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 17 #include "third_party/libxml/chromium/libxml_utils.h" | 18 #include "third_party/libxml/chromium/libxml_utils.h" |
| 18 | 19 |
| 19 // See http://crbug.com/11838 | 20 // See http://crbug.com/11838 |
| 20 TEST(Toolbar5ImporterTest, BookmarkParse) { | 21 TEST(Toolbar5ImporterTest, BookmarkParse) { |
| 21 static const string16 kTitle = ASCIIToUTF16("MyTitle"); | 22 static const string16 kTitle = ASCIIToUTF16("MyTitle"); |
| 22 static const char kUrl[] = "http://www.google.com/"; | 23 static const char kUrl[] = "http://www.google.com/"; |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 "<name>favicon_timestamp</name> <value>1153328653</value> " | 310 "<name>favicon_timestamp</name> <value>1153328653</value> " |
| 310 "</attribute> " | 311 "</attribute> " |
| 311 "<attribute> <name>notebook_name</name> <value>My notebook 0</value> " | 312 "<attribute> <name>notebook_name</name> <value>My notebook 0</value> " |
| 312 "</attribute> " | 313 "</attribute> " |
| 313 "<attribute> <name>section_name</name> <value>My section 0 " | 314 "<attribute> <name>section_name</name> <value>My section 0 " |
| 314 "</value> </attribute> </attributes> " | 315 "</value> </attribute> </attributes> " |
| 315 "</bookmark> </bookmarks>"; | 316 "</bookmark> </bookmarks>"; |
| 316 | 317 |
| 317 XmlReader reader; | 318 XmlReader reader; |
| 318 std::string bookmark_xml; | 319 std::string bookmark_xml; |
| 319 std::vector<ProfileWriter::BookmarkEntry> bookmarks; | 320 std::vector<ImportedBookmarkEntry> bookmarks; |
| 320 | 321 |
| 321 const GURL url(kUrl); | 322 const GURL url(kUrl); |
| 322 const GURL other_url(kOtherUrl); | 323 const GURL other_url(kOtherUrl); |
| 323 | 324 |
| 324 // Test doesn't work if the importer thinks this is the first run of Chromium. | 325 // Test doesn't work if the importer thinks this is the first run of Chromium. |
| 325 // Mark this as a subsequent run of the browser. | 326 // Mark this as a subsequent run of the browser. |
| 326 first_run::internal::first_run_ = first_run::internal::FIRST_RUN_FALSE; | 327 first_run::internal::first_run_ = first_run::internal::FIRST_RUN_FALSE; |
| 327 | 328 |
| 328 // Test case 1 is parsing a basic bookmark with a single label. | 329 // Test case 1 is parsing a basic bookmark with a single label. |
| 329 bookmark_xml = kGoodBookmark; | 330 bookmark_xml = kGoodBookmark; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 &bookmarks, kBookmarkGroupTitle)); | 479 &bookmarks, kBookmarkGroupTitle)); |
| 479 | 480 |
| 480 // Test case 13 tests when a bookmark has no <labels> section. | 481 // Test case 13 tests when a bookmark has no <labels> section. |
| 481 bookmark_xml = kBadBookmarkNoLabels; | 482 bookmark_xml = kBadBookmarkNoLabels; |
| 482 bookmarks.clear(); | 483 bookmarks.clear(); |
| 483 XmlReader reader13; | 484 XmlReader reader13; |
| 484 EXPECT_TRUE(reader13.Load(bookmark_xml)); | 485 EXPECT_TRUE(reader13.Load(bookmark_xml)); |
| 485 EXPECT_FALSE(Toolbar5Importer::ParseBookmarksFromReader(&reader13, | 486 EXPECT_FALSE(Toolbar5Importer::ParseBookmarksFromReader(&reader13, |
| 486 &bookmarks, kBookmarkGroupTitle)); | 487 &bookmarks, kBookmarkGroupTitle)); |
| 487 } | 488 } |
| OLD | NEW |