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

Side by Side Diff: chrome/browser/ui/tabs/tab_strip_model_unittest.cc

Issue 231173004: [WebModal] Rename NativeWebContentsModalDialogManager to SingleWebContentsDialogManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: constrained window test Created 6 years, 8 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
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/tabs/tab_strip_model.h" 5 #include "chrome/browser/ui/tabs/tab_strip_model.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 class TabStripModelTestIDUserData : public base::SupportsUserData::Data { 97 class TabStripModelTestIDUserData : public base::SupportsUserData::Data {
98 public: 98 public:
99 explicit TabStripModelTestIDUserData(int id) : id_(id) {} 99 explicit TabStripModelTestIDUserData(int id) : id_(id) {}
100 virtual ~TabStripModelTestIDUserData() {} 100 virtual ~TabStripModelTestIDUserData() {}
101 int id() { return id_; } 101 int id() { return id_; }
102 102
103 private: 103 private:
104 int id_; 104 int id_;
105 }; 105 };
106 106
107 class DummyNativeWebContentsModalDialogManager 107 class DummySingleWebContentsDialogManager
108 : public web_modal::NativeWebContentsModalDialogManager { 108 : public web_modal::SingleWebContentsDialogManager {
109 public: 109 public:
110 explicit DummyNativeWebContentsModalDialogManager( 110 explicit DummySingleWebContentsDialogManager(
111 web_modal::NativeWebContentsModalDialogManagerDelegate* delegate) 111 web_modal::SingleWebContentsDialogManagerDelegate* delegate)
112 : delegate_(delegate) {} 112 : delegate_(delegate) {}
113 virtual ~DummyNativeWebContentsModalDialogManager() {} 113 virtual ~DummySingleWebContentsDialogManager() {}
114 114
115 virtual void ManageDialog(NativeWebContentsModalDialog dialog) OVERRIDE {} 115 virtual void ManageDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
116 virtual void ShowDialog(NativeWebContentsModalDialog dialog) OVERRIDE {} 116 virtual void ShowDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
117 virtual void HideDialog(NativeWebContentsModalDialog dialog) OVERRIDE {} 117 virtual void HideDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
118 virtual void CloseDialog(NativeWebContentsModalDialog dialog) OVERRIDE { 118 virtual void CloseDialog(NativeWebContentsModalDialog dialog) OVERRIDE {
119 delegate_->WillClose(dialog); 119 delegate_->WillClose(dialog);
120 } 120 }
121 virtual void FocusDialog(NativeWebContentsModalDialog dialog) OVERRIDE {} 121 virtual void FocusDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
122 virtual void PulseDialog(NativeWebContentsModalDialog dialog) OVERRIDE {} 122 virtual void PulseDialog(NativeWebContentsModalDialog dialog) OVERRIDE {}
123 virtual void HostChanged( 123 virtual void HostChanged(
124 web_modal::WebContentsModalDialogHost* new_host) OVERRIDE {} 124 web_modal::WebContentsModalDialogHost* new_host) OVERRIDE {}
125 125
126 private: 126 private:
127 web_modal::NativeWebContentsModalDialogManagerDelegate* delegate_; 127 web_modal::SingleWebContentsDialogManagerDelegate* delegate_;
128 128
129 DISALLOW_COPY_AND_ASSIGN(DummyNativeWebContentsModalDialogManager); 129 DISALLOW_COPY_AND_ASSIGN(DummySingleWebContentsDialogManager);
130 }; 130 };
131 131
132 // Test Browser-like class for TabStripModelTest.TabBlockedState. 132 // Test Browser-like class for TabStripModelTest.TabBlockedState.
133 class TabBlockedStateTestBrowser 133 class TabBlockedStateTestBrowser
134 : public TabStripModelObserver, 134 : public TabStripModelObserver,
135 public web_modal::WebContentsModalDialogManagerDelegate { 135 public web_modal::WebContentsModalDialogManagerDelegate {
136 public: 136 public:
137 explicit TabBlockedStateTestBrowser(TabStripModel* tab_strip_model) 137 explicit TabBlockedStateTestBrowser(TabStripModel* tab_strip_model)
138 : tab_strip_model_(tab_strip_model) { 138 : tab_strip_model_(tab_strip_model) {
139 tab_strip_model_->AddObserver(this); 139 tab_strip_model_->AddObserver(this);
(...skipping 2410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2550 2550
2551 // Add another tab. 2551 // Add another tab.
2552 WebContents* contents2 = CreateWebContents(); 2552 WebContents* contents2 = CreateWebContents();
2553 web_modal::WebContentsModalDialogManager::CreateForWebContents(contents2); 2553 web_modal::WebContentsModalDialogManager::CreateForWebContents(contents2);
2554 strip_src.AppendWebContents(contents2, false); 2554 strip_src.AppendWebContents(contents2, false);
2555 2555
2556 // Create a destination tab strip. 2556 // Create a destination tab strip.
2557 TabStripModel strip_dst(&dummy_tab_strip_delegate, profile()); 2557 TabStripModel strip_dst(&dummy_tab_strip_delegate, profile());
2558 TabBlockedStateTestBrowser browser_dst(&strip_dst); 2558 TabBlockedStateTestBrowser browser_dst(&strip_dst);
2559 2559
2560 // Setup a NativeWebContentsModalDialogManager for tab |contents2|. 2560 // Setup a SingleWebContentsDialogManager for tab |contents2|.
2561 web_modal::WebContentsModalDialogManager* modal_dialog_manager = 2561 web_modal::WebContentsModalDialogManager* modal_dialog_manager =
2562 web_modal::WebContentsModalDialogManager::FromWebContents(contents2); 2562 web_modal::WebContentsModalDialogManager::FromWebContents(contents2);
2563 web_modal::WebContentsModalDialogManager::TestApi test_api( 2563 web_modal::WebContentsModalDialogManager::TestApi test_api(
2564 modal_dialog_manager); 2564 modal_dialog_manager);
2565 2565
2566 // Show a dialog that blocks tab |contents2|. 2566 // Show a dialog that blocks tab |contents2|.
2567 // DummyNativeWebContentsModalDialogManager doesn't care about the 2567 // DummySingleWebContentsDialogManager doesn't care about the
2568 // NativeWebContentsModalDialog value, so any dummy value works. 2568 // NativeWebContentsModalDialog value, so any dummy value works.
2569 DummyNativeWebContentsModalDialogManager* native_manager = 2569 DummySingleWebContentsDialogManager* native_manager =
2570 new DummyNativeWebContentsModalDialogManager(modal_dialog_manager); 2570 new DummySingleWebContentsDialogManager(modal_dialog_manager);
2571 modal_dialog_manager->ShowDialogWithManager( 2571 modal_dialog_manager->ShowDialogWithManager(
2572 reinterpret_cast<NativeWebContentsModalDialog>(0), 2572 reinterpret_cast<NativeWebContentsModalDialog>(0),
2573 scoped_ptr<web_modal::NativeWebContentsModalDialogManager>( 2573 scoped_ptr<web_modal::SingleWebContentsDialogManager>(
2574 native_manager).Pass()); 2574 native_manager).Pass());
2575 EXPECT_TRUE(strip_src.IsTabBlocked(1)); 2575 EXPECT_TRUE(strip_src.IsTabBlocked(1));
2576 2576
2577 // Detach the tab. 2577 // Detach the tab.
2578 WebContents* moved_contents = strip_src.DetachWebContentsAt(1); 2578 WebContents* moved_contents = strip_src.DetachWebContentsAt(1);
2579 EXPECT_EQ(contents2, moved_contents); 2579 EXPECT_EQ(contents2, moved_contents);
2580 2580
2581 // Attach the tab to the destination tab strip. 2581 // Attach the tab to the destination tab strip.
2582 strip_dst.AppendWebContents(moved_contents, true); 2582 strip_dst.AppendWebContents(moved_contents, true);
2583 EXPECT_TRUE(strip_dst.IsTabBlocked(0)); 2583 EXPECT_TRUE(strip_dst.IsTabBlocked(0));
2584 2584
2585 strip_dst.CloseAllTabs(); 2585 strip_dst.CloseAllTabs();
2586 strip_src.CloseAllTabs(); 2586 strip_src.CloseAllTabs();
2587 } 2587 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698