| 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/location_bar_view_mac.h" |   8 #include "chrome/browser/cocoa/location_bar_view_mac.h" | 
|   9 #include "testing/gtest/include/gtest/gtest.h" |   9 #include "testing/gtest/include/gtest/gtest.h" | 
|  10  |  10  | 
 |  11 // TODO(shess): Figure out how to unittest this.  The code below was | 
 |  12 // testing the hacked-up behavior so you didn't have to be pedantic | 
 |  13 // WRT http://.  But that approach is completely and utterly wrong in | 
 |  14 // a world where omnibox is running. | 
 |  15 // http://code.google.com/p/chromium/issues/detail?id=9977 | 
 |  16  | 
 |  17 #if 0 | 
|  11 class LocationBarViewMacTest : public testing::Test { |  18 class LocationBarViewMacTest : public testing::Test { | 
|  12  public: |  19  public: | 
|  13   LocationBarViewMacTest() |  20   LocationBarViewMacTest() | 
|  14       : field_([[NSTextField alloc] init]), |  21       : field_([[NSTextField alloc] init]), | 
|  15         locationBarView_(new LocationBarViewMac(field_)) { |  22         locationBarView_(new LocationBarViewMac(field_, NULL, NULL)) { | 
|  16   } |  23   } | 
|  17  |  24  | 
|  18   scoped_nsobject<NSTextField> field_; |  25   scoped_nsobject<NSTextField> field_; | 
|  19   scoped_ptr<LocationBarViewMac> locationBarView_; |  26   scoped_ptr<LocationBarViewMac> locationBarView_; | 
|  20 }; |  27 }; | 
|  21  |  28  | 
|  22 TEST_F(LocationBarViewMacTest, GetInputString) { |  29 TEST_F(LocationBarViewMacTest, GetInputString) { | 
|  23   // Test a few obvious cases to make sure things work end-to-end, but |  30   // Test a few obvious cases to make sure things work end-to-end, but | 
|  24   // trust url_fixer_upper_unittest.cc to do the bulk of the work. |  31   // trust url_fixer_upper_unittest.cc to do the bulk of the work. | 
|  25   [field_ setStringValue:@"ahost"]; |  32   [field_ setStringValue:@"ahost"]; | 
|  26   EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://ahost/")); |  33   EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://ahost/")); | 
|  27  |  34  | 
|  28   [field_ setStringValue:@"bhost\n"]; |  35   [field_ setStringValue:@"bhost\n"]; | 
|  29   EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://bhost/")); |  36   EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://bhost/")); | 
|  30  |  37  | 
|  31   [field_ setStringValue:@"chost/"]; |  38   [field_ setStringValue:@"chost/"]; | 
|  32   EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://chost/")); |  39   EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://chost/")); | 
|  33  |  40  | 
|  34   [field_ setStringValue:@"www.example.com"]; |  41   [field_ setStringValue:@"www.example.com"]; | 
|  35   EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://www.example.
    com/")); |  42   EXPECT_EQ(locationBarView_->GetInputString(), | 
 |  43             ASCIIToWide("http://www.example.com/")); | 
|  36  |  44  | 
|  37   [field_ setStringValue:@"http://example.com"]; |  45   [field_ setStringValue:@"http://example.com"]; | 
|  38   EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://example.com/
    ")); |  46   EXPECT_EQ(locationBarView_->GetInputString(), | 
 |  47             ASCIIToWide("http://example.com/")); | 
|  39  |  48  | 
|  40   [field_ setStringValue:@"https://www.example.com"]; |  49   [field_ setStringValue:@"https://www.example.com"]; | 
|  41   EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("https://www.example
    .com/")); |  50   EXPECT_EQ(locationBarView_->GetInputString(), | 
 |  51             ASCIIToWide("https://www.example.com/")); | 
|  42 } |  52 } | 
 |  53 #endif | 
| OLD | NEW |