| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/search/toolbar_search_animator.h" | 5 #include "chrome/browser/ui/search/toolbar_search_animator.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
| 10 #include "chrome/browser/ui/search/search.h" | 10 #include "chrome/browser/ui/search/search.h" |
| 11 #include "chrome/browser/ui/search/search_delegate.h" | 11 #include "chrome/browser/ui/search/search_delegate.h" |
| 12 #include "chrome/browser/ui/search/search_model.h" | 12 #include "chrome/browser/ui/search/search_model.h" |
| 13 #include "chrome/browser/ui/search/search_tab_helper.h" | 13 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 14 #include "chrome/browser/ui/search/toolbar_search_animator_observer.h" | 14 #include "chrome/browser/ui/search/toolbar_search_animator_observer.h" |
| 15 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
| 16 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 17 #include "chrome/test/base/browser_with_test_window_test.h" | 16 #include "chrome/test/base/browser_with_test_window_test.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "ui/base/animation/multi_animation.h" | 18 #include "ui/base/animation/multi_animation.h" |
| 20 | 19 |
| 21 // Avoid tests on branded Chrome where channel is set to CHANNEL_STABLE. | 20 // Avoid tests on branded Chrome where channel is set to CHANNEL_STABLE. |
| 22 #define AVOID_TEST_ON_BRANDED_CHROME() { \ | 21 #define AVOID_TEST_ON_BRANDED_CHROME() { \ |
| 23 if (!chrome::search::IsInstantExtendedAPIEnabled(profile())) \ | 22 if (!chrome::search::IsInstantExtendedAPIEnabled(profile())) \ |
| 24 return; \ | 23 return; \ |
| 25 } | 24 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 40 got_progressed_ = true; | 39 got_progressed_ = true; |
| 41 if (cancel_halfway_ && animator_->background_animation_.get() && | 40 if (cancel_halfway_ && animator_->background_animation_.get() && |
| 42 animator_->background_animation_->GetCurrentValue() > 0.5) { | 41 animator_->background_animation_->GetCurrentValue() > 0.5) { |
| 43 MessageLoop::current()->Quit(); | 42 MessageLoop::current()->Quit(); |
| 44 return; | 43 return; |
| 45 } | 44 } |
| 46 QuitMessageLoopIfDone(); | 45 QuitMessageLoopIfDone(); |
| 47 } | 46 } |
| 48 | 47 |
| 49 virtual void OnToolbarBackgroundAnimatorCanceled( | 48 virtual void OnToolbarBackgroundAnimatorCanceled( |
| 50 TabContents* tab_contents) OVERRIDE { | 49 content::WebContents* web_contents) OVERRIDE { |
| 51 got_canceled_ = true; | 50 got_canceled_ = true; |
| 52 if (!cancel_halfway_) | 51 if (!cancel_halfway_) |
| 53 QuitMessageLoopIfDone(); | 52 QuitMessageLoopIfDone(); |
| 54 } | 53 } |
| 55 | 54 |
| 56 virtual void OnToolbarSeparatorChanged() OVERRIDE {} | 55 virtual void OnToolbarSeparatorChanged() OVERRIDE {} |
| 57 | 56 |
| 58 void set_cancel_halfway(bool cancel) { | 57 void set_cancel_halfway(bool cancel) { |
| 59 cancel_halfway_ = cancel; | 58 cancel_halfway_ = cancel; |
| 60 } | 59 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 105 } |
| 107 | 106 |
| 108 void RemoveDefaultObserver() { | 107 void RemoveDefaultObserver() { |
| 109 if (default_observer_.get()) { | 108 if (default_observer_.get()) { |
| 110 animator().RemoveObserver(default_observer_.get()); | 109 animator().RemoveObserver(default_observer_.get()); |
| 111 default_observer_.reset(NULL); | 110 default_observer_.reset(NULL); |
| 112 } | 111 } |
| 113 } | 112 } |
| 114 | 113 |
| 115 void SetMode(const Mode::Type mode, bool animate) { | 114 void SetMode(const Mode::Type mode, bool animate) { |
| 116 TabContents* contents = chrome::GetTabContentsAt(browser(), 0); | 115 content::WebContents* web_contents = chrome::GetWebContentsAt(browser(), 0); |
| 117 contents->search_tab_helper()->model()->SetMode(Mode(mode, animate)); | 116 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model()-> |
| 117 SetMode(Mode(mode, animate)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void RunMessageLoop(bool cancel_halfway) { | 120 void RunMessageLoop(bool cancel_halfway) { |
| 121 // Run the message loop. ToolbarSearchAnimatorTestObserver quits the | 121 // Run the message loop. ToolbarSearchAnimatorTestObserver quits the |
| 122 // message loop when all animations have stopped. | 122 // message loop when all animations have stopped. |
| 123 if (default_observer_.get()) | 123 if (default_observer_.get()) |
| 124 default_observer_->set_cancel_halfway(cancel_halfway); | 124 default_observer_->set_cancel_halfway(cancel_halfway); |
| 125 message_loop()->Run(); | 125 message_loop()->Run(); |
| 126 } | 126 } |
| 127 | 127 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 SetMode(Mode::MODE_DEFAULT, true); | 282 SetMode(Mode::MODE_DEFAULT, true); |
| 283 | 283 |
| 284 RunMessageLoop(false); | 284 RunMessageLoop(false); |
| 285 | 285 |
| 286 EXPECT_TRUE(default_observer()->has_progressed()); | 286 EXPECT_TRUE(default_observer()->has_progressed()); |
| 287 EXPECT_FALSE(default_observer()->has_canceled()); | 287 EXPECT_FALSE(default_observer()->has_canceled()); |
| 288 } | 288 } |
| 289 | 289 |
| 290 } // namespace search | 290 } // namespace search |
| 291 } // namespace chrome | 291 } // namespace chrome |
| OLD | NEW |