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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller_unittest.mm

Issue 1952893002: [Mac][Material Design] Fix BookmarkBubbleControllerTest.TestBubbleWindow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.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/bookmarks/managed_bookmark_service_factory.h" 12 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
13 #include "chrome/browser/signin/signin_manager_factory.h" 13 #include "chrome/browser/signin/signin_manager_factory.h"
14 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h" 14 #include "chrome/browser/ui/bookmarks/bookmark_bubble_observer.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h" 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_controller.h"
18 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 18 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
19 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 19 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
20 #import "chrome/browser/ui/cocoa/info_bubble_window.h" 20 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
21 #include "chrome/test/base/testing_profile.h" 21 #include "chrome/test/base/testing_profile.h"
22 #include "components/bookmarks/browser/bookmark_model.h" 22 #include "components/bookmarks/browser/bookmark_model.h"
23 #include "components/bookmarks/managed/managed_bookmark_service.h" 23 #include "components/bookmarks/managed/managed_bookmark_service.h"
24 #include "components/signin/core/browser/signin_manager.h" 24 #include "components/signin/core/browser/signin_manager.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #import "testing/gtest_mac.h" 27 #import "testing/gtest_mac.h"
28 #include "testing/platform_test.h" 28 #include "testing/platform_test.h"
29 #include "ui/base/material_design/material_design_controller.h"
29 30
30 using base::ASCIIToUTF16; 31 using base::ASCIIToUTF16;
31 using bookmarks::BookmarkBubbleObserver; 32 using bookmarks::BookmarkBubbleObserver;
32 using bookmarks::BookmarkModel; 33 using bookmarks::BookmarkModel;
33 using bookmarks::BookmarkNode; 34 using bookmarks::BookmarkNode;
34 using content::WebContents; 35 using content::WebContents;
35 36
36 namespace { 37 namespace {
37 38
38 // URL of the test bookmark. 39 // URL of the test bookmark.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 114
114 bool IsWindowClosing() { 115 bool IsWindowClosing() {
115 return [static_cast<InfoBubbleWindow*>([controller_ window]) isClosing]; 116 return [static_cast<InfoBubbleWindow*>([controller_ window]) isClosing];
116 } 117 }
117 }; 118 };
118 119
119 // static 120 // static
120 int BookmarkBubbleControllerTest::edits_; 121 int BookmarkBubbleControllerTest::edits_;
121 122
122 // Confirm basics about the bubble window (e.g. that it is inside the 123 // Confirm basics about the bubble window (e.g. that it is inside the
123 // parent window) 124 // parent window)
Avi (use Gerrit) 2016/05/05 02:04:48 This comment seems not true any more.
shrike 2016/05/05 17:44:03 Fixed.
124 TEST_F(BookmarkBubbleControllerTest, TestBubbleWindow) { 125 TEST_F(BookmarkBubbleControllerTest, TestBubbleWindow) {
126 EXPECT_TRUE(ui::MaterialDesignController::IsModeMaterial());
Avi (use Gerrit) 2016/05/05 02:04:48 I don't understand this line; this would make the
shrike 2016/05/05 17:44:03 Thank you for catching that - that should not have
125 const BookmarkNode* node = CreateTestBookmark(); 127 const BookmarkNode* node = CreateTestBookmark();
126 BookmarkBubbleController* controller = ControllerForNode(node); 128 BookmarkBubbleController* controller = ControllerForNode(node);
127 EXPECT_TRUE(controller); 129 EXPECT_TRUE(controller);
128 NSWindow* window = [controller window]; 130 NSWindow* window = [controller window];
129 EXPECT_TRUE(window); 131 EXPECT_TRUE(window);
130 EXPECT_TRUE(NSContainsRect([browser()->window()->GetNativeWindow() frame], 132 NSRect browser_window_frame = [browser()->window()->GetNativeWindow() frame];
131 [window frame])); 133 // The metrics have changed slightly under Material Design, so that in this
134 // test case the bookmarks bubble is slightly outside of the window.
135 if (ui::MaterialDesignController::IsModeMaterial()) {
136 browser_window_frame.size.width += 1;
137 }
138 EXPECT_TRUE(NSContainsRect(browser_window_frame, [window frame]));
132 } 139 }
133 140
134 // Test that we can handle closing the parent window 141 // Test that we can handle closing the parent window
135 TEST_F(BookmarkBubbleControllerTest, TestClosingParentWindow) { 142 TEST_F(BookmarkBubbleControllerTest, TestClosingParentWindow) {
136 const BookmarkNode* node = CreateTestBookmark(); 143 const BookmarkNode* node = CreateTestBookmark();
137 BookmarkBubbleController* controller = ControllerForNode(node); 144 BookmarkBubbleController* controller = ControllerForNode(node);
138 EXPECT_TRUE(controller); 145 EXPECT_TRUE(controller);
139 NSWindow* window = [controller window]; 146 NSWindow* window = [controller window];
140 EXPECT_TRUE(window); 147 EXPECT_TRUE(window);
141 base::mac::ScopedNSAutoreleasePool pool; 148 base::mac::ScopedNSAutoreleasePool pool;
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // Normally this would be sent up the responder tree correctly, but since 480 // Normally this would be sent up the responder tree correctly, but since
474 // tests run in the background, key window and main window are never set on 481 // tests run in the background, key window and main window are never set on
475 // NSApplication. Adding it to NSApplication directly removes the need for 482 // NSApplication. Adding it to NSApplication directly removes the need for
476 // worrying about what the current window with focus is. 483 // worrying about what the current window with focus is.
477 - (void)editBookmarkNode:(id)sender { 484 - (void)editBookmarkNode:(id)sender {
478 EXPECT_TRUE([sender respondsToSelector:@selector(node)]); 485 EXPECT_TRUE([sender respondsToSelector:@selector(node)]);
479 BookmarkBubbleControllerTest::edits_++; 486 BookmarkBubbleControllerTest::edits_++;
480 } 487 }
481 488
482 @end 489 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698