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

Unified Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix_unittest.mm

Issue 1099403005: [AiS] changing mac omnibox suggestions form NSMatrix to NSTableView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review changes and rounding error fix Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix_unittest.mm
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix_unittest.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix_unittest.mm
index e113db576fba0f57033be2cd249179cf80c42f8f..8a3dcbc95dcb341f5135eadb57a10663fa698661 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix_unittest.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix_unittest.mm
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h"
#import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_matrix.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
@@ -9,8 +10,10 @@
namespace {
-NSEvent* MouseEventInRow(NSMatrix* matrix, NSEventType type, NSInteger row) {
- NSRect cell_rect = [matrix cellFrameAtRow:row column:0];
+NSEvent* MouseEventInRow(OmniboxPopupMatrix* matrix,
+ NSEventType type,
+ NSInteger row) {
+ NSRect cell_rect = [matrix rectOfRow:row];
NSPoint point_in_view = NSMakePoint(NSMidX(cell_rect), NSMidY(cell_rect));
NSPoint point_in_window = [matrix convertPoint:point_in_view toView:nil];
return cocoa_test_event_utils::MouseEventAtPoint(
@@ -21,20 +24,46 @@ class OmniboxPopupMatrixTest : public CocoaTest,
public OmniboxPopupMatrixDelegate {
public:
OmniboxPopupMatrixTest()
- : selected_row_(0),
- clicked_row_(0),
- middle_clicked_row_(0) {
- }
+ : selected_row_(0), clicked_row_(0), middle_clicked_row_(0) {}
void SetUp() override {
CocoaTest::SetUp();
matrix_.reset([[OmniboxPopupMatrix alloc] initWithDelegate:this]);
Scott Hess - ex-Googler 2015/05/07 22:35:42 Matrix is seeming misleading!
dschuyler 2015/05/13 01:41:11 I'd like to separate the name change to another CL
[[test_window() contentView] addSubview:matrix_];
+
+ base::scoped_nsobject<NSTableColumn> column(
+ [[NSTableColumn alloc] initWithIdentifier:@"MainCell"]);
+ [column setDataCell:[[[OmniboxPopupCell alloc] init] autorelease]];
+ [matrix_ addTableColumn:[column retain]];
Scott Hess - ex-Googler 2015/05/07 22:35:42 Seems like the receiver is going to -retain, so th
dschuyler 2015/05/13 01:41:11 Done.
+ NSInteger testWidth = 400;
+ NSInteger testHeight = 25;
Scott Hess - ex-Googler 2015/05/07 22:35:42 CGFloat, since they're floats in use below.
dschuyler 2015/05/13 01:41:11 Done.
+
+ NSMutableArray* array = [NSMutableArray array];
+ NSInteger popupHeight = 0;
Scott Hess - ex-Googler 2015/05/07 22:35:42 CGFloat here, too.
dschuyler 2015/05/13 01:41:11 Done.
+ NSRect cellRect = NSZeroRect;
+ cellRect.size.width = testWidth;
+ for (size_t ii = 0; ii < 3; ++ii) {
+ NSMutableDictionary* dictionary = [NSMutableDictionary dictionary];
+ AutocompleteMatchWrapper* acm =
+ [[[AutocompleteMatchWrapper alloc] init] autorelease];
+ [dictionary setObject:acm forKey:@"match"];
+ cellRect.origin.y = popupHeight;
+ cellRect.size.height = testHeight;
+ [dictionary setObject:[NSValue valueWithRect:cellRect] forKey:@"rect"];
+ popupHeight += testHeight;
+ [array addObject:dictionary];
+ }
+ [matrix_ setDataArray:array];
+ [matrix_ reloadData];
+
+ NSRect table_frame = NSZeroRect;
+ table_frame.size.width = testWidth;
+ table_frame.size.height = popupHeight;
+ [matrix_ setFrame:table_frame];
};
void OnMatrixRowSelected(OmniboxPopupMatrix* matrix, size_t row) override {
selected_row_ = row;
- [matrix_ selectCellAtRow:row column:0];
}
void OnMatrixRowClicked(OmniboxPopupMatrix* matrix, size_t row) override {
@@ -59,7 +88,6 @@ class OmniboxPopupMatrixTest : public CocoaTest,
TEST_VIEW(OmniboxPopupMatrixTest, matrix_);
TEST_F(OmniboxPopupMatrixTest, HighlightedRow) {
- [matrix_ renewRows:3 columns:1];
EXPECT_EQ(-1, [matrix_ highlightedRow]);
[matrix_ mouseEntered:MouseEventInRow(matrix_, NSMouseMoved, 0)];
@@ -72,8 +100,6 @@ TEST_F(OmniboxPopupMatrixTest, HighlightedRow) {
}
TEST_F(OmniboxPopupMatrixTest, SelectedRow) {
- [matrix_ renewRows:3 columns:1];
-
[NSApp postEvent:MouseEventInRow(matrix_, NSLeftMouseUp, 2) atStart:YES];
[matrix_ mouseDown:MouseEventInRow(matrix_, NSLeftMouseDown, 2)];

Powered by Google App Engine
This is Rietveld 408576698