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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/layout_view_unittest.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/ui/cocoa/autofill/layout_view.h" 5 #import "chrome/browser/ui/cocoa/autofill/layout_view.h"
6 6
7 #include "base/memory/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "chrome/browser/ui/cocoa/autofill/simple_grid_layout.h" 8 #include "chrome/browser/ui/cocoa/autofill/simple_grid_layout.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h" 10 #include "testing/platform_test.h"
11 #import "ui/base/test/ui_cocoa_test_helper.h" 11 #import "ui/base/test/ui_cocoa_test_helper.h"
12 12
13 namespace { 13 namespace {
14 14
15 class LayoutViewTest : public ui::CocoaTest { 15 class LayoutViewTest : public ui::CocoaTest {
16 public: 16 public:
17 LayoutViewTest() { 17 LayoutViewTest() {
18 CocoaTest::SetUp(); 18 CocoaTest::SetUp();
19 view_.reset([[LayoutView alloc] initWithFrame:NSZeroRect]); 19 view_.reset([[LayoutView alloc] initWithFrame:NSZeroRect]);
20 [view_ setLayoutManager: 20 [view_ setLayoutManager:
21 scoped_ptr<SimpleGridLayout>(new SimpleGridLayout(view_))]; 21 scoped_ptr<SimpleGridLayout>(new SimpleGridLayout(view_))];
22 layout_ = [view_ layoutManager]; 22 layout_ = [view_ layoutManager];
23 [[test_window() contentView] addSubview:view_]; 23 [[test_window() contentView] addSubview:view_];
24 } 24 }
25 25
26 protected: 26 protected:
27 scoped_nsobject<LayoutView> view_; 27 base::scoped_nsobject<LayoutView> view_;
28 SimpleGridLayout* layout_; // weak, owned by view_. 28 SimpleGridLayout* layout_; // weak, owned by view_.
29 }; 29 };
30 30
31 } // namespace 31 } // namespace
32 32
33 TEST_VIEW(LayoutViewTest, view_) 33 TEST_VIEW(LayoutViewTest, view_)
34 34
35 TEST_F(LayoutViewTest, setFrameInvokesLayout) { 35 TEST_F(LayoutViewTest, setFrameInvokesLayout) {
36 EXPECT_FLOAT_EQ(0, NSWidth([view_ frame])); 36 EXPECT_FLOAT_EQ(0, NSWidth([view_ frame]));
37 EXPECT_FLOAT_EQ(0, NSHeight([view_ frame])); 37 EXPECT_FLOAT_EQ(0, NSHeight([view_ frame]));
38 38
39 ColumnSet* cs = layout_->AddColumnSet(0); 39 ColumnSet* cs = layout_->AddColumnSet(0);
40 cs->AddColumn(0.4); 40 cs->AddColumn(0.4);
41 cs->AddColumn(0.6); 41 cs->AddColumn(0.6);
42 layout_->StartRow(0, 0); 42 layout_->StartRow(0, 0);
43 scoped_nsobject<NSView> childView1( 43 base::scoped_nsobject<NSView> childView1(
44 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 0, 45)]); 44 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 0, 45)]);
45 scoped_nsobject<NSView> childView2( 45 base::scoped_nsobject<NSView> childView2(
46 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 20, 55)]); 46 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 20, 55)]);
47 layout_->AddView(childView1); 47 layout_->AddView(childView1);
48 layout_->AddView(childView2); 48 layout_->AddView(childView2);
49 49
50 ASSERT_EQ(2U, [[view_ subviews] count]); 50 ASSERT_EQ(2U, [[view_ subviews] count]);
51 EXPECT_FLOAT_EQ(0, NSWidth([view_ frame])); 51 EXPECT_FLOAT_EQ(0, NSWidth([view_ frame]));
52 EXPECT_FLOAT_EQ(0, NSHeight([view_ frame])); 52 EXPECT_FLOAT_EQ(0, NSHeight([view_ frame]));
53 53
54 [view_ setFrame:NSMakeRect(0, 0, 40, 60)]; 54 [view_ setFrame:NSMakeRect(0, 0, 40, 60)];
55 EXPECT_FLOAT_EQ(40, NSWidth([view_ frame])); 55 EXPECT_FLOAT_EQ(40, NSWidth([view_ frame]));
56 EXPECT_FLOAT_EQ(60, NSHeight([view_ frame])); 56 EXPECT_FLOAT_EQ(60, NSHeight([view_ frame]));
57 57
58 NSView* subview = [[view_ subviews] objectAtIndex:0]; 58 NSView* subview = [[view_ subviews] objectAtIndex:0];
59 EXPECT_FLOAT_EQ(16, NSWidth([subview frame])); 59 EXPECT_FLOAT_EQ(16, NSWidth([subview frame]));
60 EXPECT_FLOAT_EQ(55, NSHeight([subview frame])); 60 EXPECT_FLOAT_EQ(55, NSHeight([subview frame]));
61 61
62 subview = [[view_ subviews] objectAtIndex:1]; 62 subview = [[view_ subviews] objectAtIndex:1];
63 EXPECT_FLOAT_EQ(24, NSWidth([subview frame])); 63 EXPECT_FLOAT_EQ(24, NSWidth([subview frame]));
64 EXPECT_FLOAT_EQ(55, NSHeight([subview frame])); 64 EXPECT_FLOAT_EQ(55, NSHeight([subview frame]));
65 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698