Index: chrome/browser/ui/views/sidebar/sidebar_tab_test_helper.h |
=================================================================== |
--- chrome/browser/ui/views/sidebar/sidebar_tab_test_helper.h (revision 0) |
+++ chrome/browser/ui/views/sidebar/sidebar_tab_test_helper.h (revision 0) |
@@ -0,0 +1,142 @@ |
+// 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. |
+ |
+#ifndef CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_TAB_TEST_HELPER_H_ |
+#define CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_TAB_TEST_HELPER_H_ |
+#pragma once |
+ |
+#include <map> |
+#include <string> |
+#include <vector> |
+ |
+#include "base/scoped_ptr.h" |
+#include "base/stl_util-inl.h" |
+#include "chrome/browser/sidebar/sidebar_container.h" |
+#include "chrome/browser/sidebar/sidebar_model.h" |
+#include "chrome/browser/ui/views/sidebar/sidebar_base_tab_strip.h" |
+#include "chrome/browser/ui/views/sidebar/sidebar_tab_strip_controller.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+ |
+// SidebarModel half mock, half simulated functionality. |
+class MockSidebarModel : public SidebarModel { |
+ public: |
+ virtual ~MockSidebarModel() { |
+ for (TabContentsWrapperToSidebarsMap::const_iterator it = sidebars_.begin(); |
+ it != sidebars_.end(); ++it) { |
+ STLDeleteContainerPointers(it->second.begin(), it->second.end()); |
+ } |
+ } |
+ |
+ // SidebarModel overrides. |
+ virtual std::vector<SidebarContainer*> GetAllSidebarsFor( |
+ TabContentsWrapper* tab) { |
+ TabContentsWrapperToSidebarsMap::const_iterator it = sidebars_.find(tab); |
+ if (it == sidebars_.end()) |
+ return std::vector<SidebarContainer*>(); |
+ return sidebars_[tab]; |
+ } |
+ MOCK_METHOD1(GetActiveSidebarContainerFor, |
+ SidebarContainer*(TabContentsWrapper* tab)); |
+ virtual SidebarContainer* GetSidebarContainerFor( |
+ TabContentsWrapper* tab, const std::string& content_id) { |
+ const Sidebars& tab_sidebars = sidebars_[tab]; |
+ for (Sidebars::const_iterator it = tab_sidebars.begin(); |
+ it != tab_sidebars.end(); ++it) { |
+ if ((*it)->content_id() == content_id) |
+ return *it; |
+ } |
+ return NULL; |
+ } |
+ MOCK_METHOD2(GetSidebarTabContents, |
+ TabContents*(TabContentsWrapper* tab, |
+ const std::string& content_id)); |
+ MOCK_METHOD2(NotifyStateChanges, |
+ void(TabContents* was_active_sidebar_contents, |
+ TabContents* active_sidebar_contents)); |
+ MOCK_METHOD2(ToggleSidebar, |
+ void(TabContentsWrapper* tab, const std::string& content_id)); |
+ MOCK_METHOD2(ShowSidebar, |
+ void(TabContentsWrapper* tab, const std::string& content_id)); |
+ MOCK_METHOD2(ExpandSidebar, |
+ void(TabContentsWrapper* tab, const std::string& content_id)); |
+ MOCK_METHOD2(CollapseSidebar, |
+ void(TabContentsWrapper* tab, const std::string& content_id)); |
+ MOCK_METHOD2(HideSidebar, |
+ void(TabContentsWrapper* tab, const std::string& content_id)); |
+ MOCK_METHOD3(NavigateSidebar, |
+ void(TabContentsWrapper* tab, const std::string& content_id, |
+ const GURL& url)); |
+ MOCK_METHOD3(SetSidebarBadgeText, |
+ void(TabContentsWrapper* tab, const std::string& content_id, |
+ const string16& badge_text)); |
+ MOCK_METHOD3(SetSidebarIcon, |
+ void(TabContentsWrapper* tab, const std::string& content_id, |
+ const SkBitmap& bitmap)); |
+ MOCK_METHOD3(SetSidebarTitle, |
+ void(TabContentsWrapper* tab, const std::string& content_id, |
+ const string16& title)); |
+ |
+ // Shortcuts for easier testing. |
+ void AddSidebarContainer(SidebarContainer* container) { |
+ Sidebars& sidebars = sidebars_[container->tab()]; |
+ CHECK(std::find(sidebars.begin(), sidebars.end(), container) == |
+ sidebars.end()); |
+ sidebars.push_back(container); |
+ } |
+ |
+ private: |
+ typedef std::vector<SidebarContainer*> Sidebars; |
+ typedef std::map<TabContentsWrapper*, Sidebars> |
+ TabContentsWrapperToSidebarsMap; |
+ TabContentsWrapperToSidebarsMap sidebars_; |
+}; |
+ |
+// SidebarTabStripController::Delegate mock. |
+class MockSidebarTabStripControllerDelegate |
+ : public SidebarTabStripController::Delegate { |
+ public: |
+ virtual ~MockSidebarTabStripControllerDelegate() {} |
+ |
+ MOCK_METHOD1(OnSidebarTabStripBoundsChanged, void(bool is_animating)); |
+}; |
+ |
+// SidebarTabStripController mock. |
+class MockSidebarTabStripController : public SidebarTabStripController { |
+ public: |
+ virtual ~MockSidebarTabStripController() {} |
+ |
+ MOCK_METHOD1(IsTabSelected, bool(int model_index)); |
+ MOCK_METHOD1(SelectTab, void(int model_index)); |
+ MOCK_METHOD1(UpdateTabs, void(TabContentsWrapper* tab_contents)); |
+ MOCK_METHOD1(UpdateState, void(const SidebarContainer* sidebar)); |
+ MOCK_METHOD1(UpdateLoadingState, void(const SidebarContainer* sidebar)); |
+ MOCK_METHOD1(TabStripBoundsChanged, void(bool is_animating)); |
+}; |
+ |
+// SidebarBaseTabStrip mock. |
+class MockSidebarBaseTabStrip : public SidebarBaseTabStrip { |
+ public: |
+ explicit MockSidebarBaseTabStrip(SidebarTabStripController* controller) |
+ : SidebarBaseTabStrip(controller) { |
+ } |
+ virtual ~MockSidebarBaseTabStrip() {} |
+ |
+ MOCK_METHOD3(AddTabAt, |
+ void(int model_index, bool animate, |
+ const SidebarTabRendererData& data)); |
+ MOCK_METHOD2(RemoveTabAt, void(int model_index, bool animate)); |
+ MOCK_METHOD1(SelectTabAt, void(int new_model_index)); |
+ MOCK_METHOD2(SetTabData, |
+ void(int model_index, const SidebarTabRendererData& data)); |
+ MOCK_METHOD0(SetToIdealBounds, void()); |
+ |
+ protected: |
+ MOCK_METHOD0(CreateTab, SidebarBaseTab*()); |
+ MOCK_METHOD1(StartInsertTabAnimation, void(int model_index)); |
+ MOCK_METHOD1(StartRemoveTabAnimation, void(int model_index)); |
+ MOCK_METHOD0(GenerateIdealBounds, void()); |
+}; |
+ |
+#endif // CHROME_BROWSER_UI_VIEWS_SIDEBAR_SIDEBAR_TAB_TEST_HELPER_H_ |
+ |
Property changes on: chrome\browser\ui\views\sidebar\sidebar_tab_test_helper.h |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |