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

Unified Diff: chrome/browser/cocoa/location_bar/location_bar_view_mac_unittest.mm

Issue 2805070: [Mac] First part of Omnibox decoration refactor. Enable ev bubble. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: comment clarification Created 10 years, 5 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/cocoa/location_bar/location_bar_view_mac_unittest.mm
diff --git a/chrome/browser/cocoa/location_bar/location_bar_view_mac_unittest.mm b/chrome/browser/cocoa/location_bar/location_bar_view_mac_unittest.mm
deleted file mode 100644
index 4f3c60b812f9a066024b1c04cf524f44930f9b59..0000000000000000000000000000000000000000
--- a/chrome/browser/cocoa/location_bar/location_bar_view_mac_unittest.mm
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/scoped_nsobject.h"
-#include "base/scoped_ptr.h"
-#include "base/string_util.h"
-#include "chrome/browser/cocoa/browser_test_helper.h"
-#import "chrome/browser/cocoa/cocoa_test_helper.h"
-#import "chrome/browser/cocoa/location_bar/autocomplete_text_field.h"
-#import "chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.h"
-#import "chrome/browser/cocoa/location_bar/location_bar_view_mac.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "testing/platform_test.h"
-
-// TODO(shess): Figure out how to unittest this. The code below was
-// testing the hacked-up behavior so you didn't have to be pedantic
-// WRT http://. But that approach is completely and utterly wrong in
-// a world where omnibox is running.
-// http://code.google.com/p/chromium/issues/detail?id=9977
-
-#if 0
-class LocationBarViewMacTest : public PlatformTest {
- public:
- LocationBarViewMacTest()
- : field_([[NSTextField alloc] init]),
- locationBarView_(new LocationBarViewMac(field_, NULL, NULL, NULL)) {
- }
-
- scoped_nsobject<NSTextField> field_;
- scoped_ptr<LocationBarViewMac> locationBarView_;
-};
-
-TEST_F(LocationBarViewMacTest, GetInputString) {
- // Test a few obvious cases to make sure things work end-to-end, but
- // trust url_fixer_upper_unittest.cc to do the bulk of the work.
- [field_ setStringValue:@"ahost"];
- EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://ahost/"));
-
- [field_ setStringValue:@"bhost\n"];
- EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://bhost/"));
-
- [field_ setStringValue:@"chost/"];
- EXPECT_EQ(locationBarView_->GetInputString(), ASCIIToWide("http://chost/"));
-
- [field_ setStringValue:@"www.example.com"];
- EXPECT_EQ(locationBarView_->GetInputString(),
- ASCIIToWide("http://www.example.com/"));
-
- [field_ setStringValue:@"http://example.com"];
- EXPECT_EQ(locationBarView_->GetInputString(),
- ASCIIToWide("http://example.com/"));
-
- [field_ setStringValue:@"https://www.example.com"];
- EXPECT_EQ(locationBarView_->GetInputString(),
- ASCIIToWide("https://www.example.com/"));
-}
-#endif
-
-namespace {
-
-class LocationBarViewMacTest : public CocoaTest {
- public:
- LocationBarViewMacTest() {
- // Make sure this is wide enough to play games with the cell
- // decorations.
- NSRect frame = NSMakeRect(0, 0, 400.0, 30);
- scoped_nsobject<AutocompleteTextField> field(
- [[AutocompleteTextField alloc] initWithFrame:frame]);
- field_ = field.get();
- [field_ setStringValue:@"Testing"];
- [[test_window() contentView] addSubview:field_];
- }
-
- BrowserTestHelper helper_;
- AutocompleteTextField* field_;
-};
-
-TEST_F(LocationBarViewMacTest, OnChangedImpl) {
- AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell];
- NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"];
-
- const std::wstring kKeyword(L"Google");
- NSString* const kKeywordPrefix = @"Press ";
- NSString* const kKeywordSuffix = @" to search Google";
- NSString* const kKeywordString = @"Search Google:";
- // 0x2026 is Unicode ellipses.
- NSString* const kPartialString =
- [NSString stringWithFormat:@"Search Go%C:", 0x2026];
-
- // With no special hints requested, none set.
- LocationBarViewMac::OnChangedImpl(field_, std::wstring(), std::wstring(),
- false, false, image);
- EXPECT_FALSE([cell keywordString]);
- EXPECT_FALSE([cell hintString]);
-
- // Request a keyword hint.
- LocationBarViewMac::OnChangedImpl(field_, kKeyword, kKeyword,
- true, false, image);
- EXPECT_FALSE([cell keywordString]);
- EXPECT_TRUE([[[cell hintString] string] hasPrefix:kKeywordPrefix]);
- EXPECT_TRUE([[[cell hintString] string] hasSuffix:kKeywordSuffix]);
-
- // Request keyword-search mode.
- LocationBarViewMac::OnChangedImpl(
- field_, kKeyword, kKeyword, false, false, image);
- EXPECT_TRUE([[[cell keywordString] string] hasSuffix:kKeywordString]);
- EXPECT_FALSE([cell hintString]);
-
- // Check that a partial keyword-search string is passed down in case
- // the view is narrow.
- // TODO(shess): Is this test a good argument for re-writing using a
- // mock field?
- NSRect frame([field_ frame]);
- frame.size.width = 10.0;
- [field_ setFrame:frame];
- LocationBarViewMac::OnChangedImpl(field_, kKeyword, kKeyword, false,
- false, image);
- EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kPartialString]);
- EXPECT_FALSE([cell hintString]);
-
- // Transition back to baseline.
- LocationBarViewMac::OnChangedImpl(
- field_, std::wstring(), std::wstring(), false, false, image);
- EXPECT_FALSE([cell keywordString]);
- EXPECT_FALSE([cell hintString]);
-}
-
-} // namespace

Powered by Google App Engine
This is Rietveld 408576698