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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Fix Bookmark and Global error unittests Created 3 years, 9 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 (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 "chrome/browser/ui/views/bookmarks/bookmark_editor_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_editor_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h"
13 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
14 #include "components/bookmarks/browser/bookmark_model.h" 15 #include "components/bookmarks/browser/bookmark_model.h"
15 #include "components/bookmarks/test/bookmark_test_helpers.h" 16 #include "components/bookmarks/test/bookmark_test_helpers.h"
16 #include "content/public/test/test_browser_thread_bundle.h" 17 #include "content/public/test/test_browser_thread_bundle.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/views/controls/textfield/textfield.h" 19 #include "ui/views/controls/textfield/textfield.h"
19 #include "ui/views/controls/tree/tree_view.h" 20 #include "ui/views/controls/tree/tree_view.h"
20 #include "ui/views/test/test_views_delegate.h" 21 #include "ui/views/test/test_views_delegate.h"
21 22
22 using base::ASCIIToUTF16; 23 using base::ASCIIToUTF16;
23 using base::UTF8ToUTF16; 24 using base::UTF8ToUTF16;
24 using base::Time; 25 using base::Time;
25 using base::TimeDelta; 26 using base::TimeDelta;
26 using bookmarks::BookmarkModel; 27 using bookmarks::BookmarkModel;
27 using bookmarks::BookmarkNode; 28 using bookmarks::BookmarkNode;
28 29
29 // Base class for bookmark editor tests. Creates a BookmarkModel and populates 30 // Base class for bookmark editor tests. Creates a BookmarkModel and populates
30 // it with test data. 31 // it with test data.
31 class BookmarkEditorViewTest : public testing::Test { 32 class BookmarkEditorViewTest : public testing::Test {
32 public: 33 public:
33 BookmarkEditorViewTest() : model_(nullptr) {} 34 BookmarkEditorViewTest() : model_(nullptr) {}
34 35
35 void SetUp() override { 36 void SetUp() override {
36 profile_.reset(new TestingProfile()); 37 profile_.reset(new TestingProfile());
37 profile_->CreateBookmarkModel(true); 38 profile_->CreateBookmarkModel(true);
38 39
40 views_delegate_.set_layout_delegate(nullptr);
Peter Kasting 2017/03/24 22:51:13 Why is this line needed? Same comment elsewhere t
kylix_rd 2017/03/27 18:18:27 Since these delegates are singletons and they set/
Peter Kasting 2017/03/27 20:06:48 This sounds like the API is easy to subtly use wro
kylix_rd 2017/03/29 18:56:04 Short of imposing more conditions on its use, I'm
41 views_delegate_.set_layout_delegate(
42 base::MakeUnique<ChromeViewsLayoutDelegate>());
43
39 model_ = BookmarkModelFactory::GetForBrowserContext(profile_.get()); 44 model_ = BookmarkModelFactory::GetForBrowserContext(profile_.get());
40 bookmarks::test::WaitForBookmarkModelToLoad(model_); 45 bookmarks::test::WaitForBookmarkModelToLoad(model_);
41 46
42 AddTestData(); 47 AddTestData();
43 } 48 }
44 49
45 protected: 50 protected:
46 std::string base_path() const { return "file:///c:/tmp/"; } 51 std::string base_path() const { return "file:///c:/tmp/"; }
47 52
48 const BookmarkNode* GetNode(const std::string& name) { 53 const BookmarkNode* GetNode(const std::string& name) {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 ASSERT_TRUE(tree_view()->editor() != NULL); 450 ASSERT_TRUE(tree_view()->editor() != NULL);
446 tree_view()->editor()->SetText(ASCIIToUTF16("modified")); 451 tree_view()->editor()->SetText(ASCIIToUTF16("modified"));
447 ApplyEdits(); 452 ApplyEdits();
448 453
449 // Verify the new folder was added and title set appropriately. 454 // Verify the new folder was added and title set appropriately.
450 ASSERT_EQ(1, parent->child_count()); 455 ASSERT_EQ(1, parent->child_count());
451 const BookmarkNode* new_folder = parent->GetChild(0); 456 const BookmarkNode* new_folder = parent->GetChild(0);
452 ASSERT_TRUE(new_folder->is_folder()); 457 ASSERT_TRUE(new_folder->is_folder());
453 EXPECT_EQ("modified", base::UTF16ToASCII(new_folder->GetTitle())); 458 EXPECT_EQ("modified", base::UTF16ToASCII(new_folder->GetTitle()));
454 } 459 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698