Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: components/bookmarks/browser/bookmark_model_unittest.cc

Issue 2367533003: Always add bookmarks to the mobile node on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Put new method into ifdef Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/bookmarks/browser/bookmark_model.h" 5 #include "components/bookmarks/browser/bookmark_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 866
867 // Copy '2' to be after 'a': Folder within the bar. 867 // Copy '2' to be after 'a': Folder within the bar.
868 node_to_copy = root->GetChild(4); 868 node_to_copy = root->GetChild(4);
869 model_->Copy(node_to_copy, root, 1); 869 model_->Copy(node_to_copy, root, 1);
870 actual_model_string = test::ModelStringFromNode(root); 870 actual_model_string = test::ModelStringFromNode(root);
871 EXPECT_EQ("a 2:[ e 1:[ b d c ] f 1:[ b d c ] g ] d 1:[ b d c ] " 871 EXPECT_EQ("a 2:[ e 1:[ b d c ] f 1:[ b d c ] g ] d 1:[ b d c ] "
872 "d 2:[ e 1:[ b d c ] f 1:[ b d c ] g ] h d ", 872 "d 2:[ e 1:[ b d c ] f 1:[ b d c ] g ] h d ",
873 actual_model_string); 873 actual_model_string);
874 } 874 }
875 875
876 // Tests the default node if no bookmarks have been added yet
877 TEST_F(BookmarkModelTest, ParentForNewNodesWithEmptyModel) {
878 #if defined(OS_ANDROID)
879 ASSERT_EQ(model_->mobile_node(), GetParentForNewNodes(model_.get()));
880 #else
881 ASSERT_EQ(model_->bookmark_bar_node(), GetParentForNewNodes(model_.get()));
882 #endif
883 }
884
885 #if defined(OS_ANDROID)
886 // Tests that the bookmark_bar_node can still be returned even on Android in
887 // case the last bookmark was added to it.
888 TEST_F(BookmarkModelTest, ParentCanBeBookmarkBarOnAndroid) {
889 const base::string16 title(ASCIIToUTF16("foo"));
890 const GURL url("http://foo.com");
891
892 model_->AddURL(model_->bookmark_bar_node(), 0, title, url);
893 ASSERT_EQ(model_->bookmark_bar_node(), GetParentForNewNodes(model_.get()));
894 }
895 #endif
896
876 // Tests that adding a URL to a folder updates the last modified time. 897 // Tests that adding a URL to a folder updates the last modified time.
877 TEST_F(BookmarkModelTest, ParentForNewNodes) { 898 TEST_F(BookmarkModelTest, ParentForNewNodes) {
878 ASSERT_EQ(model_->bookmark_bar_node(), model_->GetParentForNewNodes());
879
880 const base::string16 title(ASCIIToUTF16("foo")); 899 const base::string16 title(ASCIIToUTF16("foo"));
881 const GURL url("http://foo.com"); 900 const GURL url("http://foo.com");
882 901
883 model_->AddURL(model_->other_node(), 0, title, url); 902 model_->AddURL(model_->other_node(), 0, title, url);
884 ASSERT_EQ(model_->other_node(), model_->GetParentForNewNodes()); 903 ASSERT_EQ(model_->other_node(), GetParentForNewNodes(model_.get()));
885 } 904 }
886 905
887 // Tests that adding a URL to a folder updates the last modified time. 906 // Tests that adding a URL to a folder updates the last modified time.
888 TEST_F(BookmarkModelTest, ParentForNewMobileNodes) { 907 TEST_F(BookmarkModelTest, ParentForNewMobileNodes) {
889 ASSERT_EQ(model_->bookmark_bar_node(), model_->GetParentForNewNodes());
890
891 const base::string16 title(ASCIIToUTF16("foo")); 908 const base::string16 title(ASCIIToUTF16("foo"));
892 const GURL url("http://foo.com"); 909 const GURL url("http://foo.com");
893 910
894 model_->AddURL(model_->mobile_node(), 0, title, url); 911 model_->AddURL(model_->mobile_node(), 0, title, url);
895 ASSERT_EQ(model_->mobile_node(), model_->GetParentForNewNodes()); 912 ASSERT_EQ(model_->mobile_node(), GetParentForNewNodes(model_.get()));
896 } 913 }
897 914
898 // Make sure recently modified stays in sync when adding a URL. 915 // Make sure recently modified stays in sync when adding a URL.
899 TEST_F(BookmarkModelTest, MostRecentlyModifiedFolders) { 916 TEST_F(BookmarkModelTest, MostRecentlyModifiedFolders) {
900 // Add a folder. 917 // Add a folder.
901 const BookmarkNode* folder = 918 const BookmarkNode* folder =
902 model_->AddFolder(model_->other_node(), 0, ASCIIToUTF16("foo")); 919 model_->AddFolder(model_->other_node(), 0, ASCIIToUTF16("foo"));
903 // Add a URL to it. 920 // Add a URL to it.
904 model_->AddURL(folder, 0, ASCIIToUTF16("blah"), GURL("http://foo.com")); 921 model_->AddURL(folder, 0, ASCIIToUTF16("blah"), GURL("http://foo.com"));
905 922
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1397 std::set<GURL> changed_page_urls; 1414 std::set<GURL> changed_page_urls;
1398 changed_page_urls.insert(kPageURL1); 1415 changed_page_urls.insert(kPageURL1);
1399 model_->OnFaviconsChanged(changed_page_urls, kFaviconURL12); 1416 model_->OnFaviconsChanged(changed_page_urls, kFaviconURL12);
1400 ASSERT_EQ(2u, updated_nodes_.size()); 1417 ASSERT_EQ(2u, updated_nodes_.size());
1401 EXPECT_TRUE(WasNodeUpdated(node1)); 1418 EXPECT_TRUE(WasNodeUpdated(node1));
1402 EXPECT_TRUE(WasNodeUpdated(node2)); 1419 EXPECT_TRUE(WasNodeUpdated(node2));
1403 } 1420 }
1404 } 1421 }
1405 1422
1406 } // namespace bookmarks 1423 } // namespace bookmarks
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698