| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 6 | 6 |
| 7 #import "chrome/browser/ui/browser_window.h" | 7 #import "chrome/browser/ui/browser_window.h" |
| 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 9 #include "chrome/browser/ui/cocoa/location_bar/mock_toolbar_model.h" |
| 9 #import "chrome/browser/ui/cocoa/location_bar/search_token_decoration.h" | 10 #import "chrome/browser/ui/cocoa/location_bar/search_token_decoration.h" |
| 10 #import "chrome/browser/ui/cocoa/location_bar/separator_decoration.h" | 11 #import "chrome/browser/ui/cocoa/location_bar/separator_decoration.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 12 | 13 |
| 13 namespace { | |
| 14 | |
| 15 // Override the toolbar model to allow |GetInputInProgress| and | |
| 16 // |WouldReplaceSearchURLWithSearchTerms| to be customized. | |
| 17 class MockToolbarModel : public ToolbarModel { | |
| 18 public: | |
| 19 MockToolbarModel() : ToolbarModel(), | |
| 20 input_in_progress_(false), | |
| 21 would_replace_search_url_with_search_terms_(false) {} | |
| 22 virtual ~MockToolbarModel() {} | |
| 23 | |
| 24 virtual string16 GetText( | |
| 25 bool display_search_urls_as_search_terms) const OVERRIDE { | |
| 26 return string16(); | |
| 27 } | |
| 28 virtual GURL GetURL() const OVERRIDE { return GURL(); } | |
| 29 virtual bool WouldReplaceSearchURLWithSearchTerms() const OVERRIDE { | |
| 30 return would_replace_search_url_with_search_terms_; | |
| 31 } | |
| 32 virtual SecurityLevel GetSecurityLevel() const OVERRIDE { return NONE; } | |
| 33 virtual int GetIcon() const OVERRIDE { return 0; } | |
| 34 virtual string16 GetEVCertName() const OVERRIDE { return string16(); } | |
| 35 virtual bool ShouldDisplayURL() const OVERRIDE { return false; } | |
| 36 virtual void SetInputInProgress(bool value) OVERRIDE { | |
| 37 input_in_progress_ = value; | |
| 38 } | |
| 39 virtual bool GetInputInProgress() const OVERRIDE { | |
| 40 return input_in_progress_; | |
| 41 } | |
| 42 | |
| 43 void set_would_replace_search_url_with_search_terms(bool value) { | |
| 44 would_replace_search_url_with_search_terms_ = value; | |
| 45 } | |
| 46 | |
| 47 private: | |
| 48 bool input_in_progress_; | |
| 49 bool would_replace_search_url_with_search_terms_; | |
| 50 }; | |
| 51 | |
| 52 } // namespace | |
| 53 | |
| 54 class LocationBarViewMacBrowserTest : public InProcessBrowserTest { | 14 class LocationBarViewMacBrowserTest : public InProcessBrowserTest { |
| 55 public: | 15 public: |
| 56 LocationBarViewMacBrowserTest() : InProcessBrowserTest(), | 16 LocationBarViewMacBrowserTest() : InProcessBrowserTest(), |
| 57 old_toolbar_model_(NULL) { | 17 old_toolbar_model_(NULL) { |
| 58 } | 18 } |
| 59 | 19 |
| 60 protected: | 20 protected: |
| 61 virtual void SetUpOnMainThread() OVERRIDE { | 21 virtual void SetUpOnMainThread() OVERRIDE { |
| 62 old_toolbar_model_ = GetLocationBar()->toolbar_model_; | 22 old_toolbar_model_ = GetLocationBar()->toolbar_model_; |
| 63 GetLocationBar()->toolbar_model_ = &mock_toolbar_model_; | 23 GetLocationBar()->toolbar_model_ = &mock_toolbar_model_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 mock_toolbar_model_.set_would_replace_search_url_with_search_terms(true); | 62 mock_toolbar_model_.set_would_replace_search_url_with_search_terms(true); |
| 103 GetLocationBar()->Layout(); | 63 GetLocationBar()->Layout(); |
| 104 EXPECT_TRUE(GetSearchTokenDecoration()->IsVisible()); | 64 EXPECT_TRUE(GetSearchTokenDecoration()->IsVisible()); |
| 105 EXPECT_TRUE(GetSeparatorDecoration()->IsVisible()); | 65 EXPECT_TRUE(GetSeparatorDecoration()->IsVisible()); |
| 106 | 66 |
| 107 mock_toolbar_model_.SetInputInProgress(true); | 67 mock_toolbar_model_.SetInputInProgress(true); |
| 108 GetLocationBar()->Layout(); | 68 GetLocationBar()->Layout(); |
| 109 EXPECT_FALSE(GetSearchTokenDecoration()->IsVisible()); | 69 EXPECT_FALSE(GetSearchTokenDecoration()->IsVisible()); |
| 110 EXPECT_FALSE(GetSeparatorDecoration()->IsVisible()); | 70 EXPECT_FALSE(GetSeparatorDecoration()->IsVisible()); |
| 111 } | 71 } |
| OLD | NEW |