diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 20:15:35 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-27 20:15:35 +0000 |
commit | 7745b82920b6a761f316c78a85e7af8742434f1c (patch) | |
tree | d942f01dd45823d55c223dcfb868012d8194c82a /chrome/test/test_location_bar.h | |
parent | 41910d1c4de903e0337ae41a9c835d918f8e264a (diff) | |
download | chromium_src-7745b82920b6a761f316c78a85e7af8742434f1c.zip chromium_src-7745b82920b6a761f316c78a85e7af8742434f1c.tar.gz chromium_src-7745b82920b6a761f316c78a85e7af8742434f1c.tar.bz2 |
Re-land this from earlier... unit tests no longer crash.
Extract a cross platform LocationBar interface.
Adds a TestLocationBar object that unit tests can use to mock the location bar (fixes NULL deref).
Review URL: http://codereview.chromium.org/18851
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8745 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/test_location_bar.h')
-rw-r--r-- | chrome/test/test_location_bar.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/chrome/test/test_location_bar.h b/chrome/test/test_location_bar.h new file mode 100644 index 0000000..6f9b2ab --- /dev/null +++ b/chrome/test/test_location_bar.h @@ -0,0 +1,53 @@ +// Copyright (c) 2009 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. + +#ifndef CHROME_TEST_TEST_LOCATION_BAR_H_ +#define CHROME_TEST_TEST_LOCATION_BAR_H_ + +#include "chrome/browser/location_bar.h" +#include "chrome/common/page_transition_types.h" +#include "webkit/glue/window_open_disposition.h" + +class TestLocationBar : public LocationBar { + public: + TestLocationBar() + : disposition_(CURRENT_TAB), + transition_(PageTransition::LINK) { + } + + void set_input_string(const std::wstring& input_string) { + input_string_ = input_string; + } + void set_disposition(WindowOpenDisposition disposition) { + disposition_ = disposition; + } + void set_transition(PageTransition::Type transition) { + transition_ = transition; + } + + // Overridden from LocationBar: + virtual void ShowFirstRunBubble() {} + virtual std::wstring GetInputString() const { return input_string_; } + virtual WindowOpenDisposition GetWindowOpenDisposition() const { + return disposition_; + } + virtual PageTransition::Type GetPageTransition() const { return transition_; } + virtual void AcceptInput() {} + virtual void FocusLocation() {} + virtual void FocusSearch() {} + virtual void SaveStateToContents(TabContents* contents) {} + + private: + + // Test-supplied values that will be returned through the LocationBar + // interface. + std::wstring input_string_; + WindowOpenDisposition disposition_; + PageTransition::Type transition_; + + DISALLOW_COPY_AND_ASSIGN(TestLocationBar); +}; + + +#endif // #ifndef CHROME_TEST_TEST_LOCATION_BAR_H_ |