OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
6 #include "base/scoped_ptr.h" | 6 #include "base/scoped_ptr.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "chrome/browser/cocoa/autocomplete_text_field.h" | 8 #include "chrome/browser/cocoa/autocomplete_text_field.h" |
9 #include "chrome/browser/cocoa/autocomplete_text_field_cell.h" | 9 #include "chrome/browser/cocoa/autocomplete_text_field_cell.h" |
10 #include "chrome/browser/cocoa/browser_test_helper.h" | 10 #include "chrome/browser/cocoa/browser_test_helper.h" |
11 #include "chrome/browser/cocoa/location_bar_view_mac.h" | 11 #include "chrome/browser/cocoa/location_bar_view_mac.h" |
12 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 12 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "testing/platform_test.h" |
14 | 15 |
15 // TODO(shess): Figure out how to unittest this. The code below was | 16 // TODO(shess): Figure out how to unittest this. The code below was |
16 // testing the hacked-up behavior so you didn't have to be pedantic | 17 // testing the hacked-up behavior so you didn't have to be pedantic |
17 // WRT http://. But that approach is completely and utterly wrong in | 18 // WRT http://. But that approach is completely and utterly wrong in |
18 // a world where omnibox is running. | 19 // a world where omnibox is running. |
19 // http://code.google.com/p/chromium/issues/detail?id=9977 | 20 // http://code.google.com/p/chromium/issues/detail?id=9977 |
20 | 21 |
21 #if 0 | 22 #if 0 |
22 class LocationBarViewMacTest : public testing::Test { | 23 class LocationBarViewMacTest : public PlatformTest { |
23 public: | 24 public: |
24 LocationBarViewMacTest() | 25 LocationBarViewMacTest() |
25 : field_([[NSTextField alloc] init]), | 26 : field_([[NSTextField alloc] init]), |
26 locationBarView_(new LocationBarViewMac(field_, NULL, NULL, NULL)) { | 27 locationBarView_(new LocationBarViewMac(field_, NULL, NULL, NULL)) { |
27 } | 28 } |
28 | 29 |
29 scoped_nsobject<NSTextField> field_; | 30 scoped_nsobject<NSTextField> field_; |
30 scoped_ptr<LocationBarViewMac> locationBarView_; | 31 scoped_ptr<LocationBarViewMac> locationBarView_; |
31 }; | 32 }; |
32 | 33 |
(...skipping 18 matching lines...) Expand all Loading... |
51 ASCIIToWide("http://example.com/")); | 52 ASCIIToWide("http://example.com/")); |
52 | 53 |
53 [field_ setStringValue:@"https://www.example.com"]; | 54 [field_ setStringValue:@"https://www.example.com"]; |
54 EXPECT_EQ(locationBarView_->GetInputString(), | 55 EXPECT_EQ(locationBarView_->GetInputString(), |
55 ASCIIToWide("https://www.example.com/")); | 56 ASCIIToWide("https://www.example.com/")); |
56 } | 57 } |
57 #endif | 58 #endif |
58 | 59 |
59 namespace { | 60 namespace { |
60 | 61 |
61 class LocationBarViewMacTest : public testing::Test { | 62 class LocationBarViewMacTest : public PlatformTest { |
62 public: | 63 public: |
63 LocationBarViewMacTest() { | 64 LocationBarViewMacTest() { |
64 // Make sure this is wide enough to play games with the cell | 65 // Make sure this is wide enough to play games with the cell |
65 // decorations. | 66 // decorations. |
66 NSRect frame = NSMakeRect(0, 0, 300, 30); | 67 NSRect frame = NSMakeRect(0, 0, 300, 30); |
67 field_.reset([[AutocompleteTextField alloc] initWithFrame:frame]); | 68 field_.reset([[AutocompleteTextField alloc] initWithFrame:frame]); |
68 [field_ setStringValue:@"Testing"]; | 69 [field_ setStringValue:@"Testing"]; |
69 [cocoa_helper_.contentView() addSubview:field_.get()]; | 70 [cocoa_helper_.contentView() addSubview:field_.get()]; |
70 } | 71 } |
71 | 72 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 EXPECT_FALSE([cell hintString]); | 122 EXPECT_FALSE([cell hintString]); |
122 | 123 |
123 // Transition back to baseline. | 124 // Transition back to baseline. |
124 LocationBarViewMac::OnChangedImpl( | 125 LocationBarViewMac::OnChangedImpl( |
125 field_.get(), std::wstring(), std::wstring(), false, false, image); | 126 field_.get(), std::wstring(), std::wstring(), false, false, image); |
126 EXPECT_FALSE([cell keywordString]); | 127 EXPECT_FALSE([cell keywordString]); |
127 EXPECT_FALSE([cell hintString]); | 128 EXPECT_FALSE([cell hintString]); |
128 } | 129 } |
129 | 130 |
130 } // namespace | 131 } // namespace |
OLD | NEW |