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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac_browsertest.mm

Issue 12042002: Alternate NTP: Add search token to omnibox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update separator color Created 7 years, 10 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
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
6
7 #import "chrome/browser/ui/browser_window.h"
8 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
9 #import "chrome/browser/ui/cocoa/location_bar/search_token_decoration.h"
10 #import "chrome/browser/ui/cocoa/location_bar/separator_decoration.h"
11 #include "chrome/test/base/in_process_browser_test.h"
12
13 namespace {
14
15 class MockToolbarModel : public ToolbarModel {
Scott Hess - ex-Googler 2013/01/29 23:28:37 I have no idea what's really happening in here, bu
sail 2013/01/30 01:40:56 Done. Added comment :-P
16 public:
17 MockToolbarModel() : ToolbarModel(),
18 input_in_progress_(false),
19 would_replace_search_url_with_search_terms_(false) {}
20 virtual ~MockToolbarModel() {}
21
22 virtual string16 GetText(
23 bool display_search_urls_as_search_terms) const OVERRIDE {
24 return string16();
25 }
26 virtual GURL GetURL() const OVERRIDE { return GURL(); }
27 virtual bool WouldReplaceSearchURLWithSearchTerms() const OVERRIDE {
28 return would_replace_search_url_with_search_terms_;
29 }
30 virtual SecurityLevel GetSecurityLevel() const OVERRIDE { return NONE; }
31 virtual int GetIcon() const OVERRIDE { return 0; }
32 virtual string16 GetEVCertName() const OVERRIDE { return string16(); }
33 virtual bool ShouldDisplayURL() const OVERRIDE { return false; }
34 virtual void SetInputInProgress(bool value) OVERRIDE {
35 input_in_progress_ = value;
36 }
37 virtual bool GetInputInProgress() const OVERRIDE {
38 return input_in_progress_;
39 }
40
41 void set_would_replace_search_url_with_search_terms(bool value) {
42 would_replace_search_url_with_search_terms_ = value;
43 }
44
45 private:
46 bool input_in_progress_;
47 bool would_replace_search_url_with_search_terms_;
48 };
49
50 } // namespace
51
52 class LocationBarViewMacBrowserTest : public InProcessBrowserTest {
53 public:
54 LocationBarViewMacBrowserTest() : InProcessBrowserTest(),
55 old_toolbar_model_(NULL) {
56 }
57
58 protected:
59 virtual void SetUpOnMainThread() OVERRIDE {
60 old_toolbar_model_ = GetLocationBar()->toolbar_model_;
61 GetLocationBar()->toolbar_model_ = &mock_toolbar_model_;
62 }
63
64 virtual void CleanUpOnMainThread() OVERRIDE {
65 GetLocationBar()->toolbar_model_ = old_toolbar_model_;
66 }
67
68 LocationBarViewMac* GetLocationBar() const {
69 BrowserWindowController* controller =
70 [BrowserWindowController browserWindowControllerForWindow:
71 browser()->window()->GetNativeWindow()];
72 return [controller locationBarBridge];
73 }
74
75 SearchTokenDecoration* GetSearchTokenDecoration() const {
76 return GetLocationBar()->search_token_decoration_.get();
77 }
78
79 SeparatorDecoration* GetSeparatorDecoration() const {
80 return GetLocationBar()->separator_decoration_.get();
81 }
82
83 protected:
84 MockToolbarModel mock_toolbar_model_;
85
86 private:
87 ToolbarModel* old_toolbar_model_;
88
89 DISALLOW_COPY_AND_ASSIGN(LocationBarViewMacBrowserTest);
90 };
91
92 // Verify that the search token decoration is displayed when there are search
93 // terms in the omnibox.
94 IN_PROC_BROWSER_TEST_F(LocationBarViewMacBrowserTest, SearchToken) {
95 GetLocationBar()->Layout();
96 EXPECT_FALSE(GetSearchTokenDecoration()->IsVisible());
97 EXPECT_FALSE(GetSeparatorDecoration()->IsVisible());
98
99 mock_toolbar_model_.SetInputInProgress(false);
100 mock_toolbar_model_.set_would_replace_search_url_with_search_terms(true);
101 GetLocationBar()->Layout();
102 EXPECT_TRUE(GetSearchTokenDecoration()->IsVisible());
103 EXPECT_TRUE(GetSeparatorDecoration()->IsVisible());
104
105 mock_toolbar_model_.SetInputInProgress(true);
106 GetLocationBar()->Layout();
107 EXPECT_FALSE(GetSearchTokenDecoration()->IsVisible());
108 EXPECT_FALSE(GetSeparatorDecoration()->IsVisible());
109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698