OLD | NEW |
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 <gtk/gtk.h> | 5 #include <gtk/gtk.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/bookmarks/bookmark_model.h" | 12 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
13 #include "chrome/browser/ui/gtk/bookmarks/bookmark_editor_gtk.h" | 14 #include "chrome/browser/ui/gtk/bookmarks/bookmark_editor_gtk.h" |
14 #include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h" | 15 #include "chrome/browser/ui/gtk/bookmarks/bookmark_tree_model.h" |
15 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
16 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 | 19 |
19 using base::Time; | 20 using base::Time; |
20 using base::TimeDelta; | 21 using base::TimeDelta; |
21 using bookmark_utils::GetTitleFromTreeIter; | 22 using bookmark_utils::GetTitleFromTreeIter; |
22 using content::BrowserThread; | 23 using content::BrowserThread; |
23 | 24 |
24 // Base class for bookmark editor tests. This class is a copy from | 25 // Base class for bookmark editor tests. This class is a copy from |
25 // bookmark_editor_view_unittest.cc, and all the tests in this file are | 26 // bookmark_editor_view_unittest.cc, and all the tests in this file are |
26 // GTK-ifications of the corresponding views tests. Testing here is really | 27 // GTK-ifications of the corresponding views tests. Testing here is really |
27 // important because on Linux, we make round trip copies from chrome's | 28 // important because on Linux, we make round trip copies from chrome's |
28 // BookmarkModel class to GTK's native GtkTreeStore. | 29 // BookmarkModel class to GTK's native GtkTreeStore. |
29 class BookmarkEditorGtkTest : public testing::Test { | 30 class BookmarkEditorGtkTest : public testing::Test { |
30 public: | 31 public: |
31 BookmarkEditorGtkTest() | 32 BookmarkEditorGtkTest() |
32 : model_(NULL), | 33 : model_(NULL), |
33 ui_thread_(BrowserThread::UI, &message_loop_), | 34 ui_thread_(BrowserThread::UI, &message_loop_), |
34 file_thread_(BrowserThread::FILE, &message_loop_) { | 35 file_thread_(BrowserThread::FILE, &message_loop_) { |
35 } | 36 } |
36 | 37 |
37 virtual void SetUp() OVERRIDE { | 38 virtual void SetUp() OVERRIDE { |
38 profile_.reset(new TestingProfile()); | 39 profile_.reset(new TestingProfile()); |
39 profile_->CreateBookmarkModel(true); | 40 profile_->CreateBookmarkModel(true); |
40 profile_->BlockUntilBookmarkModelLoaded(); | 41 profile_->BlockUntilBookmarkModelLoaded(); |
41 | 42 |
42 model_ = profile_->GetBookmarkModel(); | 43 model_ = BookmarkModelFactory::GetForProfile(profile_.get()); |
43 | 44 |
44 AddTestData(); | 45 AddTestData(); |
45 } | 46 } |
46 | 47 |
47 virtual void TearDown() OVERRIDE { | 48 virtual void TearDown() OVERRIDE { |
48 } | 49 } |
49 | 50 |
50 protected: | 51 protected: |
51 std::string base_path() const { return "file:///c:/tmp/"; } | 52 std::string base_path() const { return "file:///c:/tmp/"; } |
52 | 53 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 gtk_entry_set_text(GTK_ENTRY(editor.name_entry_), "new_a"); | 337 gtk_entry_set_text(GTK_ENTRY(editor.name_entry_), "new_a"); |
337 | 338 |
338 editor.ApplyEdits(); | 339 editor.ApplyEdits(); |
339 | 340 |
340 const BookmarkNode* other_node = model_->other_node(); | 341 const BookmarkNode* other_node = model_->other_node(); |
341 ASSERT_EQ(2, other_node->child_count()); | 342 ASSERT_EQ(2, other_node->child_count()); |
342 | 343 |
343 const BookmarkNode* new_node = other_node->GetChild(0); | 344 const BookmarkNode* new_node = other_node->GetChild(0); |
344 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); | 345 EXPECT_EQ(ASCIIToUTF16("new_a"), new_node->GetTitle()); |
345 } | 346 } |
OLD | NEW |