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

Side by Side Diff: ui/base/cocoa/controls/hyperlink_text_view_unittest.mm

Issue 2440913003: Fix issue with broken links in HyperlinkTextView. (Closed)
Patch Set: Add unit test. Created 4 years, 1 month 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 | « ui/base/cocoa/controls/hyperlink_text_view.mm ('k') | no next file » | 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) 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 "base/mac/scoped_nsobject.h" 5 #include "base/mac/scoped_nsobject.h"
6 #include "testing/gtest_mac.h" 6 #include "testing/gtest_mac.h"
7 #import "ui/base/cocoa/controls/hyperlink_text_view.h" 7 #import "ui/base/cocoa/controls/hyperlink_text_view.h"
8 #import "ui/gfx/test/ui_cocoa_test_helper.h" 8 #import "ui/gfx/test/ui_cocoa_test_helper.h"
9 9
10 namespace { 10 namespace {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 HyperlinkTextView* view_; 53 HyperlinkTextView* view_;
54 54
55 private: 55 private:
56 base::scoped_nsobject<NSMutableDictionary> linkAttributes_; 56 base::scoped_nsobject<NSMutableDictionary> linkAttributes_;
57 }; 57 };
58 58
59 TEST_VIEW(HyperlinkTextViewTest, view_); 59 TEST_VIEW(HyperlinkTextViewTest, view_);
60 60
61 TEST_F(HyperlinkTextViewTest, TestSelectionRange) {
62 NSRange actualRange;
63
64 // The length of the selection range should be 0.
65 actualRange = [view_ selectionRangeForProposedRange:NSMakeRange(0, 20)
66 granularity:NSSelectByCharacter];
67 EXPECT_TRUE(NSEqualRanges(NSMakeRange(0, 0), actualRange));
68
69 // While the location should always match the location of the proposed range.
70 actualRange = [view_ selectionRangeForProposedRange:NSMakeRange(50, 100)
71 granularity:NSSelectByCharacter];
72 EXPECT_TRUE(NSEqualRanges(NSMakeRange(50, 0), actualRange));
73 }
74
61 TEST_F(HyperlinkTextViewTest, TestViewConfiguration) { 75 TEST_F(HyperlinkTextViewTest, TestViewConfiguration) {
62 EXPECT_FALSE([view_ isEditable]); 76 EXPECT_FALSE([view_ isEditable]);
63 EXPECT_FALSE([view_ drawsBackground]); 77 EXPECT_FALSE([view_ drawsBackground]);
64 EXPECT_FALSE([view_ isHorizontallyResizable]); 78 EXPECT_FALSE([view_ isHorizontallyResizable]);
65 EXPECT_FALSE([view_ isVerticallyResizable]); 79 EXPECT_FALSE([view_ isVerticallyResizable]);
66 } 80 }
67 81
68 TEST_F(HyperlinkTextViewTest, TestSetMessage) { 82 TEST_F(HyperlinkTextViewTest, TestSetMessage) {
69 // Verifies setMessage sets text and attributes properly. 83 // Verifies setMessage sets text and attributes properly.
70 NSString* message = @"Test message"; 84 NSString* message = @"Test message";
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 145
132 TEST_F(HyperlinkTextViewTest, FirstResponderBehavior) { 146 TEST_F(HyperlinkTextViewTest, FirstResponderBehavior) {
133 // By default, accept. 147 // By default, accept.
134 EXPECT_TRUE([view_ acceptsFirstResponder]); 148 EXPECT_TRUE([view_ acceptsFirstResponder]);
135 149
136 [view_ setRefusesFirstResponder:YES]; 150 [view_ setRefusesFirstResponder:YES];
137 EXPECT_FALSE([view_ acceptsFirstResponder]); 151 EXPECT_FALSE([view_ acceptsFirstResponder]);
138 } 152 }
139 153
140 } // namespace 154 } // namespace
OLDNEW
« no previous file with comments | « ui/base/cocoa/controls/hyperlink_text_view.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698