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

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

Issue 8561031: Replace ScopedCommandLineOverride with TestSuite listener. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 7
8 #include "base/base_paths.h" 8 #include "base/base_paths.h"
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h"
11 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
12 #include "base/file_util.h" 11 #include "base/file_util.h"
13 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
14 #include "base/path_service.h" 13 #include "base/path_service.h"
15 #include "base/string16.h" 14 #include "base/string16.h"
16 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
17 #include "base/string_split.h" 16 #include "base/string_split.h"
18 #include "base/string_util.h" 17 #include "base/string_util.h"
19 #include "base/utf_string_conversions.h" 18 #include "base/utf_string_conversions.h"
20 #include "chrome/browser/bookmarks/bookmark_model.h" 19 #include "chrome/browser/bookmarks/bookmark_model.h"
21 #include "chrome/browser/bookmarks/bookmark_model_observer.h" 20 #include "chrome/browser/bookmarks/bookmark_model_observer.h"
22 #include "chrome/browser/bookmarks/bookmark_utils.h" 21 #include "chrome/browser/bookmarks/bookmark_utils.h"
23 #include "chrome/browser/history/history_notifications.h" 22 #include "chrome/browser/history/history_notifications.h"
24 #include "chrome/common/chrome_constants.h" 23 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/chrome_notification_types.h" 24 #include "chrome/common/chrome_notification_types.h"
26 #include "chrome/common/chrome_paths.h" 25 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
28 #include "chrome/test/base/model_test_utils.h" 27 #include "chrome/test/base/model_test_utils.h"
28 #include "chrome/test/base/scoped_command_line_override.h"
29 #include "chrome/test/base/testing_profile.h" 29 #include "chrome/test/base/testing_profile.h"
30 #include "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
31 #include "content/public/browser/notification_registrar.h" 31 #include "content/public/browser/notification_registrar.h"
32 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
33 #include "content/test/test_browser_thread.h" 33 #include "content/test/test_browser_thread.h"
34 #include "testing/gtest/include/gtest/gtest.h" 34 #include "testing/gtest/include/gtest/gtest.h"
35 #include "ui/base/models/tree_node_iterator.h" 35 #include "ui/base/models/tree_node_iterator.h"
36 #include "ui/base/models/tree_node_model.h" 36 #include "ui/base/models/tree_node_model.h"
37 37
38 using base::Time; 38 using base::Time;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 private: 83 private:
84 const BookmarkNode* node1_; 84 const BookmarkNode* node1_;
85 const BookmarkNode* node2_; 85 const BookmarkNode* node2_;
86 int index1_; 86 int index1_;
87 int index2_; 87 int index2_;
88 }; 88 };
89 89
90 BookmarkModelTest() 90 BookmarkModelTest()
91 : model_(NULL), 91 : model_(NULL) {
92 original_command_line_(*CommandLine::ForCurrentProcess()) {
93 model_.AddObserver(this); 92 model_.AddObserver(this);
94 ClearCounts(); 93 ClearCounts();
95 } 94 }
96 95
97 virtual void TearDown() OVERRIDE {
98 *CommandLine::ForCurrentProcess() = original_command_line_;
99 }
100
101 void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE { 96 void Loaded(BookmarkModel* model, bool ids_reassigned) OVERRIDE {
102 // We never load from the db, so that this should never get invoked. 97 // We never load from the db, so that this should never get invoked.
103 NOTREACHED(); 98 NOTREACHED();
104 } 99 }
105 100
106 virtual void BookmarkNodeMoved(BookmarkModel* model, 101 virtual void BookmarkNodeMoved(BookmarkModel* model,
107 const BookmarkNode* old_parent, 102 const BookmarkNode* old_parent,
108 int old_index, 103 int old_index,
109 const BookmarkNode* new_parent, 104 const BookmarkNode* new_parent,
110 int new_index) OVERRIDE { 105 int new_index) OVERRIDE {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 EXPECT_EQ(removed_count_, removed_count); 155 EXPECT_EQ(removed_count_, removed_count);
161 EXPECT_EQ(changed_count_, changed_count); 156 EXPECT_EQ(changed_count_, changed_count);
162 EXPECT_EQ(reordered_count_, reordered_count); 157 EXPECT_EQ(reordered_count_, reordered_count);
163 } 158 }
164 159
165 protected: 160 protected:
166 BookmarkModel model_; 161 BookmarkModel model_;
167 ObserverDetails observer_details_; 162 ObserverDetails observer_details_;
168 163
169 private: 164 private:
170 CommandLine original_command_line_;
171
172 int added_count_; 165 int added_count_;
173 int moved_count_; 166 int moved_count_;
174 int removed_count_; 167 int removed_count_;
175 int changed_count_; 168 int changed_count_;
176 int reordered_count_; 169 int reordered_count_;
177 170
178 DISALLOW_COPY_AND_ASSIGN(BookmarkModelTest); 171 DISALLOW_COPY_AND_ASSIGN(BookmarkModelTest);
179 }; 172 };
180 173
181 TEST_F(BookmarkModelTest, InitialState) { 174 TEST_F(BookmarkModelTest, InitialState) {
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 1015
1023 // Arbitrary node should be visible 1016 // Arbitrary node should be visible
1024 TestNode bbn; 1017 TestNode bbn;
1025 PopulateNodeFromString("B", &bbn); 1018 PopulateNodeFromString("B", &bbn);
1026 const BookmarkNode* parent = model_.bookmark_bar_node(); 1019 const BookmarkNode* parent = model_.bookmark_bar_node();
1027 PopulateBookmarkNode(&bbn, &model_, parent); 1020 PopulateBookmarkNode(&bbn, &model_, parent);
1028 EXPECT_TRUE(parent->GetChild(0)->IsVisible()); 1021 EXPECT_TRUE(parent->GetChild(0)->IsVisible());
1029 } 1022 }
1030 1023
1031 TEST_F(BookmarkModelTest, SyncNodeVisibileIfFlagSet) { 1024 TEST_F(BookmarkModelTest, SyncNodeVisibileIfFlagSet) {
1032 CommandLine::ForCurrentProcess()->AppendSwitch( 1025 ScopedCommandLineOverride override(switches::kEnableSyncedBookmarksFolder);
1033 switches::kEnableSyncedBookmarksFolder);
1034 EXPECT_TRUE(model_.synced_node()->IsVisible()); 1026 EXPECT_TRUE(model_.synced_node()->IsVisible());
1035 } 1027 }
1036 1028
1037 TEST_F(BookmarkModelTest, SyncNodeVisibileWithChildren) { 1029 TEST_F(BookmarkModelTest, SyncNodeVisibileWithChildren) {
1038 const BookmarkNode* root = model_.synced_node(); 1030 const BookmarkNode* root = model_.synced_node();
1039 const string16 title(ASCIIToUTF16("foo")); 1031 const string16 title(ASCIIToUTF16("foo"));
1040 const GURL url("http://foo.com"); 1032 const GURL url("http://foo.com");
1041 1033
1042 model_.AddURL(root, 0, title, url); 1034 model_.AddURL(root, 0, title, url);
1043 EXPECT_TRUE(model_.synced_node()->IsVisible()); 1035 EXPECT_TRUE(model_.synced_node()->IsVisible());
1044 } 1036 }
1045 1037
1046 } // namespace 1038 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/history/top_sites_unittest.cc » ('j') | chrome/test/base/scoped_command_line_override.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698