Home | History | Annotate | Download | only in importer
      1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h"
      6 
      7 #include <string>
      8 #include <vector>
      9 
     10 #include "base/string16.h"
     11 #include "base/string_util.h"
     12 #include "base/utf_string_conversions.h"
     13 #include "chrome/browser/first_run/first_run.h"
     14 #include "chrome/browser/importer/toolbar_importer.h"
     15 #include "chrome/common/libxml_utils.h"
     16 #include "googleurl/src/gurl.h"
     17 
     18 // See http://crbug.com/11838
     19 TEST(Toolbar5ImporterTest, BookmarkParse) {
     20 static const string16 kTitle = ASCIIToUTF16("MyTitle");
     21 static const char kUrl[] = "http://www.google.com/";
     22 static const string16 kFolder = ASCIIToUTF16("Google");
     23 static const string16 kFolder2 = ASCIIToUTF16("Homepage");
     24 static const string16 kFolderArray[3] = {
     25   ASCIIToUTF16("Google"),
     26   ASCIIToUTF16("Search"),
     27   ASCIIToUTF16("Page")
     28 };
     29 static const string16 kOtherTitle = ASCIIToUTF16("MyOtherTitle");
     30 static const char* kOtherUrl = "http://www.google.com/mail";
     31 static const string16 kOtherFolder = ASCIIToUTF16("Mail");
     32 
     33 static const string16 kBookmarkGroupTitle = ASCIIToUTF16("BookmarkGroupTitle");
     34 
     35 // Since the following is very dense to read I enumerate the test cases here.
     36 // 1. Correct bookmark structure with one label.
     37 // 2. Correct bookmark structure with no labels.
     38 // 3. Correct bookmark structure with two labels.
     39 // 4. Correct bookmark structure with a folder->label translation by toolbar.
     40 // 5. Correct bookmark structure with no favicon.
     41 // 6. Two correct bookmarks.
     42 // The following are error cases by removing sections from the xml:
     43 // 7. Empty string passed as xml.
     44 // 8. No <bookmarks> section in the xml.
     45 // 9. No <bookmark> section below the <bookmarks> section.
     46 // 10. No <title> in a <bookmark> section.
     47 // 11. No <url> in a <bookmark> section.
     48 // 12. No <timestamp> in a <bookmark> section.
     49 // 13. No <labels> in a <bookmark> section.
     50 static const char* kGoodBookmark =
     51     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
     52     " <bookmark> "
     53     "<title>MyTitle</title> "
     54     "<url>http://www.google.com/</url> "
     55     "<timestamp>1153328691085181</timestamp> "
     56     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
     57     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
     58     "<labels> <label>Google</label> </labels> "
     59     "<attributes> "
     60     "<attribute> "
     61     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
     62     "</attribute> "
     63     "<attribute> "
     64     "<name>favicon_timestamp</name> <value>1153328653</value> "
     65     "</attribute> "
     66     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
     67     "</attribute> "
     68     "<attribute> <name>section_name</name> <value>My section 0 "
     69     "</value> </attribute> </attributes> "
     70     "</bookmark> </bookmarks>";
     71 static const char* kGoodBookmarkNoLabel =
     72     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
     73     " <bookmark> "
     74     "<title>MyTitle</title> "
     75     "<url>http://www.google.com/</url> "
     76     "<timestamp>1153328691085181</timestamp> "
     77     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
     78     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
     79     "<labels> </labels> "
     80     "<attributes> "
     81     "<attribute> "
     82     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
     83     "</attribute> "
     84     "<attribute> "
     85     "<name>favicon_timestamp</name> <value>1153328653</value> "
     86     "</attribute> "
     87     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
     88     "</attribute> "
     89     "<attribute> <name>section_name</name> <value>My section 0 "
     90     "</value> </attribute> </attributes> "
     91     "</bookmark> </bookmarks>";
     92 static const char* kGoodBookmarkTwoLabels =
     93     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
     94     " <bookmark> "
     95     "<title>MyTitle</title> "
     96     "<url>http://www.google.com/</url> "
     97     "<timestamp>1153328691085181</timestamp> "
     98     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
     99     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    100     "<labels> <label>Google</label> <label>Homepage</label> </labels> "
    101     "<attributes> "
    102     "<attribute> "
    103     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
    104     "</attribute> "
    105     "<attribute> "
    106     "<name>favicon_timestamp</name> <value>1153328653</value> "
    107     "</attribute> "
    108     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    109     "</attribute> "
    110     "<attribute> <name>section_name</name> <value>My section 0 "
    111     "</value> </attribute> </attributes> "
    112     "</bookmark> </bookmarks>";
    113 static const char* kGoodBookmarkFolderLabel =
    114     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
    115     " <bookmark> "
    116     "<title>MyTitle</title> "
    117     "<url>http://www.google.com/</url> "
    118     "<timestamp>1153328691085181</timestamp> "
    119     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    120     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    121     "<labels> <label>Google:Search:Page</label> </labels> "
    122     "<attributes> "
    123     "<attribute> "
    124     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
    125     "</attribute> "
    126     "<attribute> "
    127     "<name>favicon_timestamp</name> <value>1153328653</value> "
    128     "</attribute> "
    129     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    130     "</attribute> "
    131     "<attribute> <name>section_name</name> <value>My section 0 "
    132     "</value> </attribute> </attributes> "
    133     "</bookmark> </bookmarks>";
    134 static const char* kGoodBookmarkNoFavicon =
    135     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
    136     " <bookmark> "
    137     "<title>MyTitle</title> "
    138     "<url>http://www.google.com/</url> "
    139     "<timestamp>1153328691085181</timestamp> "
    140     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    141     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    142     "<labels> <label>Google</label> </labels> "
    143     "<attributes> "
    144     "<attribute> "
    145     "<name>favicon_timestamp</name> <value>1153328653</value> "
    146     "</attribute> "
    147     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    148     "</attribute> "
    149     "<attribute> <name>section_name</name> <value>My section 0 "
    150     "</value> </attribute> </attributes> "
    151     "</bookmark> </bookmarks>";
    152 static const char* kGoodBookmark2Items =
    153     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
    154     " <bookmark> "
    155     "<title>MyTitle</title> "
    156     "<url>http://www.google.com/</url> "
    157     "<timestamp>1153328691085181</timestamp> "
    158     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    159     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    160     "<labels> <label>Google</label> </labels> "
    161     "<attributes> "
    162     "<attribute> "
    163     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
    164     "</attribute> "
    165     "<attribute> "
    166     "<name>favicon_timestamp</name> <value>1153328653</value> "
    167     "</attribute> "
    168     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    169     "</attribute> "
    170     "<attribute> <name>section_name</name> <value>My section 0 "
    171     "</value> </attribute> </attributes> "
    172     "</bookmark>"
    173     " <bookmark> "
    174     "<title>MyOtherTitle</title> "
    175     "<url>http://www.google.com/mail</url> "
    176     "<timestamp>1153328691085181</timestamp> "
    177     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    178     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    179     "<labels> <label>Mail</label> </labels> "
    180     "<attributes> "
    181     "<attribute> "
    182     "<name>favicon_url</name>"
    183     "<value>http://www.google.com/mail/favicon.ico</value> "
    184     "</attribute> "
    185     "<attribute> "
    186     "<name>favicon_timestamp</name> <value>1253328653</value> "
    187     "</attribute> "
    188     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    189     "</attribute> "
    190     "<attribute> <name>section_name</name> <value>My section 0 "
    191     "</value> </attribute> </attributes> "
    192     "</bookmark>"
    193     "</bookmarks>";
    194 static const char* kEmptyString = "";
    195 static const char* kBadBookmarkNoBookmarks =
    196     " <bookmark> "
    197     "<title>MyTitle</title> "
    198     "<url>http://www.google.com/</url> "
    199     "<timestamp>1153328691085181</timestamp> "
    200     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    201     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    202     "<labels> <label>Google</label> </labels> "
    203     "<attributes> "
    204     "<attribute> "
    205     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
    206     "</attribute> "
    207     "<attribute> "
    208     "<name>favicon_timestamp</name> <value>1153328653</value> "
    209     "</attribute> "
    210     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    211     "</attribute> "
    212     "<attribute> <name>section_name</name> <value>My section 0 "
    213     "</value> </attribute> </attributes> "
    214     "</bookmark> </bookmarks>";
    215 static const char* kBadBookmarkNoBookmark =
    216     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
    217     "<title>MyTitle</title> "
    218     "<url>http://www.google.com/</url> "
    219     "<timestamp>1153328691085181</timestamp> "
    220     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    221     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    222     "<labels> <label>Google</label> </labels> "
    223     "<attributes> "
    224     "<attribute> "
    225     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
    226     "</attribute> "
    227     "<attribute> "
    228     "<name>favicon_timestamp</name> <value>1153328653</value> "
    229     "</attribute> "
    230     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    231     "</attribute> "
    232     "<attribute> <name>section_name</name> <value>My section 0 "
    233     "</value> </attribute> </attributes> "
    234     "</bookmark> </bookmarks>";
    235 static const char* kBadBookmarkNoTitle =
    236     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
    237     " <bookmark> "
    238     "<url>http://www.google.com/</url> "
    239     "<timestamp>1153328691085181</timestamp> "
    240     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    241     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    242     "<labels> <label>Google</label> </labels> "
    243     "<attributes> "
    244     "<attribute> "
    245     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
    246     "</attribute> "
    247     "<attribute> "
    248     "<name>favicon_timestamp</name> <value>1153328653</value> "
    249     "</attribute> "
    250     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    251     "</attribute> "
    252     "<attribute> <name>section_name</name> <value>My section 0 "
    253     "</value> </attribute> </attributes> "
    254     "</bookmark> </bookmarks>";
    255 static const char* kBadBookmarkNoUrl =
    256     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
    257     " <bookmark> "
    258     "<title>MyTitle</title> "
    259     "<timestamp>1153328691085181</timestamp> "
    260     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    261     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    262     "<labels> <label>Google</label> </labels> "
    263     "<attributes> "
    264     "<attribute> "
    265     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
    266     "</attribute> "
    267     "<attribute> "
    268     "<name>favicon_timestamp</name> <value>1153328653</value> "
    269     "</attribute> "
    270     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    271     "</attribute> "
    272     "<attribute> <name>section_name</name> <value>My section 0 "
    273     "</value> </attribute> </attributes> "
    274     "</bookmark> </bookmarks>";
    275 static const char* kBadBookmarkNoTimestamp =
    276     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
    277     " <bookmark> "
    278     "<title>MyTitle</title> "
    279     "<url>http://www.google.com/</url> "
    280     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    281     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    282     "<labels> <label>Google</label> </labels> "
    283     "<attributes> "
    284     "<attribute> "
    285     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
    286     "</attribute> "
    287     "<attribute> "
    288     "<name>favicon_timestamp</name> <value>1153328653</value> "
    289     "</attribute> "
    290     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    291     "</attribute> "
    292     "<attribute> <name>section_name</name> <value>My section 0 "
    293     "</value> </attribute> </attributes> "
    294     "</bookmark> </bookmarks>";
    295 static const char* kBadBookmarkNoLabels =
    296     "<?xml version=\"1.0\" ?> <xml_api_reply version=\"1\"> <bookmarks>"
    297     " <bookmark> "
    298     "<title>MyTitle</title> "
    299     "<url>http://www.google.com/</url> "
    300     "<timestamp>1153328691085181</timestamp> "
    301     "<id>N123nasdf239</id> <notebook_id>Bxxxxxxx</notebook_id> "
    302     "<section_id>Sxxxxxx</section_id> <has_highlight>0</has_highlight>"
    303     "<attributes> "
    304     "<attribute> "
    305     "<name>favicon_url</name> <value>http://www.google.com/favicon.ico</value> "
    306     "</attribute> "
    307     "<attribute> "
    308     "<name>favicon_timestamp</name> <value>1153328653</value> "
    309     "</attribute> "
    310     "<attribute> <name>notebook_name</name> <value>My notebook 0</value> "
    311     "</attribute> "
    312     "<attribute> <name>section_name</name> <value>My section 0 "
    313     "</value> </attribute> </attributes> "
    314     "</bookmark> </bookmarks>";
    315 
    316   XmlReader reader;
    317   std::string bookmark_xml;
    318   std::vector<ProfileWriter::BookmarkEntry> bookmarks;
    319 
    320   const GURL url(kUrl);
    321   const GURL other_url(kOtherUrl);
    322 
    323   // Test doesn't work if the importer thinks this is the first run of Chromium.
    324   // Mark this as a subsequent run of the browser.
    325   FirstRun::first_run_ = FirstRun::FIRST_RUN_FALSE;
    326 
    327   // Test case 1 is parsing a basic bookmark with a single label.
    328   bookmark_xml = kGoodBookmark;
    329   bookmarks.clear();
    330   XmlReader reader1;
    331   EXPECT_TRUE(reader1.Load(bookmark_xml));
    332   EXPECT_TRUE(Toolbar5Importer::ParseBookmarksFromReader(&reader1, &bookmarks,
    333       kBookmarkGroupTitle));
    334 
    335   ASSERT_EQ(1U, bookmarks.size());
    336   EXPECT_FALSE(bookmarks[0].in_toolbar);
    337   EXPECT_EQ(kTitle, bookmarks[0].title);
    338   EXPECT_EQ(url, bookmarks[0].url);
    339   ASSERT_EQ(2U, bookmarks[0].path.size());
    340   EXPECT_EQ(kFolder, bookmarks[0].path[1]);
    341 
    342   // Test case 2 is parsing a single bookmark with no label.
    343   bookmark_xml = kGoodBookmarkNoLabel;
    344   bookmarks.clear();
    345   XmlReader reader2;
    346   EXPECT_TRUE(reader2.Load(bookmark_xml));
    347   EXPECT_TRUE(Toolbar5Importer::ParseBookmarksFromReader(&reader2, &bookmarks,
    348       kBookmarkGroupTitle));
    349 
    350   ASSERT_EQ(1U, bookmarks.size());
    351   EXPECT_FALSE(bookmarks[0].in_toolbar);
    352   EXPECT_EQ(kTitle, bookmarks[0].title);
    353   EXPECT_EQ(url, bookmarks[0].url);
    354   EXPECT_EQ(1U, bookmarks[0].path.size());
    355 
    356   // Test case 3 is parsing a single bookmark with two labels.
    357   bookmark_xml = kGoodBookmarkTwoLabels;
    358   bookmarks.clear();
    359   XmlReader reader3;
    360   EXPECT_TRUE(reader3.Load(bookmark_xml));
    361   EXPECT_TRUE(Toolbar5Importer::ParseBookmarksFromReader(&reader3, &bookmarks,
    362       kBookmarkGroupTitle));
    363 
    364   ASSERT_EQ(2U, bookmarks.size());
    365   EXPECT_FALSE(bookmarks[0].in_toolbar);
    366   EXPECT_FALSE(bookmarks[1].in_toolbar);
    367   EXPECT_EQ(kTitle, bookmarks[0].title);
    368   EXPECT_EQ(kTitle, bookmarks[1].title);
    369   EXPECT_EQ(url, bookmarks[0].url);
    370   EXPECT_EQ(url, bookmarks[1].url);
    371   ASSERT_EQ(2U, bookmarks[0].path.size());
    372   EXPECT_EQ(kFolder, bookmarks[0].path[1]);
    373   ASSERT_EQ(2U, bookmarks[1].path.size());
    374   EXPECT_EQ(kFolder2, bookmarks[1].path[1]);
    375 
    376   // Test case 4 is parsing a single bookmark which has a label with a colon,
    377   // this test file name translation between Toolbar and Chrome.
    378   bookmark_xml = kGoodBookmarkFolderLabel;
    379   bookmarks.clear();
    380   XmlReader reader4;
    381   EXPECT_TRUE(reader4.Load(bookmark_xml));
    382   EXPECT_TRUE(Toolbar5Importer::ParseBookmarksFromReader(&reader4, &bookmarks,
    383       kBookmarkGroupTitle));
    384 
    385   ASSERT_EQ(1U, bookmarks.size());
    386   EXPECT_FALSE(bookmarks[0].in_toolbar);
    387   EXPECT_EQ(kTitle, bookmarks[0].title);
    388   EXPECT_EQ(url, bookmarks[0].url);
    389   ASSERT_EQ(4U, bookmarks[0].path.size());
    390   EXPECT_EQ(string16(kFolderArray[0]),
    391             bookmarks[0].path[1]);
    392   EXPECT_EQ(string16(kFolderArray[1]),
    393             bookmarks[0].path[2]);
    394   EXPECT_EQ(string16(kFolderArray[2]),
    395             bookmarks[0].path[3]);
    396 
    397   // Test case 5 is parsing a single bookmark without a favicon URL.
    398   bookmark_xml = kGoodBookmarkNoFavicon;
    399   bookmarks.clear();
    400   XmlReader reader5;
    401   EXPECT_TRUE(reader5.Load(bookmark_xml));
    402   EXPECT_TRUE(Toolbar5Importer::ParseBookmarksFromReader(&reader5, &bookmarks,
    403       kBookmarkGroupTitle));
    404 
    405   ASSERT_EQ(1U, bookmarks.size());
    406   EXPECT_FALSE(bookmarks[0].in_toolbar);
    407   EXPECT_EQ(kTitle, bookmarks[0].title);
    408   EXPECT_EQ(url, bookmarks[0].url);
    409   ASSERT_EQ(2U, bookmarks[0].path.size());
    410   EXPECT_EQ(kFolder, bookmarks[0].path[1]);
    411 
    412   // Test case 6 is parsing two bookmarks.
    413   bookmark_xml = kGoodBookmark2Items;
    414   bookmarks.clear();
    415   XmlReader reader6;
    416   EXPECT_TRUE(reader6.Load(bookmark_xml));
    417   EXPECT_TRUE(Toolbar5Importer::ParseBookmarksFromReader(&reader6, &bookmarks,
    418       kBookmarkGroupTitle));
    419 
    420   ASSERT_EQ(2U, bookmarks.size());
    421   EXPECT_FALSE(bookmarks[0].in_toolbar);
    422   EXPECT_FALSE(bookmarks[1].in_toolbar);
    423   EXPECT_EQ(kTitle, bookmarks[0].title);
    424   EXPECT_EQ(kOtherTitle, bookmarks[1].title);
    425   EXPECT_EQ(url, bookmarks[0].url);
    426   EXPECT_EQ(other_url, bookmarks[1].url);
    427   ASSERT_EQ(2U, bookmarks[0].path.size());
    428   EXPECT_EQ(kFolder, bookmarks[0].path[1]);
    429   ASSERT_EQ(2U, bookmarks[1].path.size());
    430   EXPECT_EQ(kOtherFolder, bookmarks[1].path[1]);
    431 
    432   // Test case 7 is parsing an empty string for bookmarks.
    433   bookmark_xml = kEmptyString;
    434   bookmarks.clear();
    435   XmlReader reader7;
    436   EXPECT_FALSE(reader7.Load(bookmark_xml));
    437 
    438   // Test case 8 is testing the error when no <bookmarks> section is present.
    439   bookmark_xml = kBadBookmarkNoBookmarks;
    440   bookmarks.clear();
    441   XmlReader reader8;
    442   EXPECT_TRUE(reader8.Load(bookmark_xml));
    443   EXPECT_FALSE(Toolbar5Importer::ParseBookmarksFromReader(&reader8,
    444       &bookmarks, kBookmarkGroupTitle));
    445 
    446   // Test case 9 tests when no <bookmark> section is present.
    447   bookmark_xml = kBadBookmarkNoBookmark;
    448   bookmarks.clear();
    449   XmlReader reader9;
    450   EXPECT_TRUE(reader9.Load(bookmark_xml));
    451   EXPECT_FALSE(Toolbar5Importer::ParseBookmarksFromReader(&reader9,
    452       &bookmarks, kBookmarkGroupTitle));
    453 
    454 
    455   // Test case 10 tests when a bookmark has no <title> section.
    456   bookmark_xml = kBadBookmarkNoTitle;
    457   bookmarks.clear();
    458   XmlReader reader10;
    459   EXPECT_TRUE(reader10.Load(bookmark_xml));
    460   EXPECT_FALSE(Toolbar5Importer::ParseBookmarksFromReader(&reader10,
    461       &bookmarks, kBookmarkGroupTitle));
    462 
    463   // Test case 11 tests when a bookmark has no <url> section.
    464   bookmark_xml = kBadBookmarkNoUrl;
    465   bookmarks.clear();
    466   XmlReader reader11;
    467   EXPECT_TRUE(reader11.Load(bookmark_xml));
    468   EXPECT_FALSE(Toolbar5Importer::ParseBookmarksFromReader(&reader11,
    469       &bookmarks, kBookmarkGroupTitle));
    470 
    471   // Test case 12 tests when a bookmark has no <timestamp> section.
    472   bookmark_xml = kBadBookmarkNoTimestamp;
    473   bookmarks.clear();
    474   XmlReader reader12;
    475   EXPECT_TRUE(reader12.Load(bookmark_xml));
    476   EXPECT_FALSE(Toolbar5Importer::ParseBookmarksFromReader(&reader12,
    477       &bookmarks, kBookmarkGroupTitle));
    478 
    479   // Test case 13 tests when a bookmark has no <labels> section.
    480   bookmark_xml = kBadBookmarkNoLabels;
    481   bookmarks.clear();
    482   XmlReader reader13;
    483   EXPECT_TRUE(reader13.Load(bookmark_xml));
    484   EXPECT_FALSE(Toolbar5Importer::ParseBookmarksFromReader(&reader13,
    485       &bookmarks, kBookmarkGroupTitle));
    486 }
    487