| 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/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 Loading... |
| 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 2366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 | 2506 |
| 2507 // Add another tab. | 2507 // Add another tab. |
| 2508 WebContents* contents2 = CreateWebContents(); | 2508 WebContents* contents2 = CreateWebContents(); |
| 2509 web_modal::WebContentsModalDialogManager::CreateForWebContents(contents2); | 2509 web_modal::WebContentsModalDialogManager::CreateForWebContents(contents2); |
| 2510 strip_src.AppendWebContents(contents2, false); | 2510 strip_src.AppendWebContents(contents2, false); |
| 2511 | 2511 |
| 2512 // Create a destination tab strip. | 2512 // Create a destination tab strip. |
| 2513 TabStripModel strip_dst(&dummy_tab_strip_delegate, profile()); | 2513 TabStripModel strip_dst(&dummy_tab_strip_delegate, profile()); |
| 2514 TabBlockedStateTestBrowser browser_dst(&strip_dst); | 2514 TabBlockedStateTestBrowser browser_dst(&strip_dst); |
| 2515 | 2515 |
| 2516 // Setup a NativeWebContentsModalDialogManager for tab |contents2|. | 2516 // Setup a SingleWebContentsDialogManager for tab |contents2|. |
| 2517 web_modal::WebContentsModalDialogManager* modal_dialog_manager = | 2517 web_modal::WebContentsModalDialogManager* modal_dialog_manager = |
| 2518 web_modal::WebContentsModalDialogManager::FromWebContents(contents2); | 2518 web_modal::WebContentsModalDialogManager::FromWebContents(contents2); |
| 2519 web_modal::WebContentsModalDialogManager::TestApi test_api( | 2519 web_modal::WebContentsModalDialogManager::TestApi test_api( |
| 2520 modal_dialog_manager); | 2520 modal_dialog_manager); |
| 2521 | 2521 |
| 2522 // Show a dialog that blocks tab |contents2|. | 2522 // Show a dialog that blocks tab |contents2|. |
| 2523 // DummyNativeWebContentsModalDialogManager doesn't care about the | 2523 // DummySingleWebContentsDialogManager doesn't care about the |
| 2524 // NativeWebContentsModalDialog value, so any dummy value works. | 2524 // NativeWebContentsModalDialog value, so any dummy value works. |
| 2525 DummyNativeWebContentsModalDialogManager* native_manager = | 2525 DummySingleWebContentsDialogManager* native_manager = |
| 2526 new DummyNativeWebContentsModalDialogManager(modal_dialog_manager); | 2526 new DummySingleWebContentsDialogManager(modal_dialog_manager); |
| 2527 modal_dialog_manager->ShowDialogWithManager( | 2527 modal_dialog_manager->ShowDialogWithManager( |
| 2528 reinterpret_cast<NativeWebContentsModalDialog>(0), | 2528 reinterpret_cast<NativeWebContentsModalDialog>(0), |
| 2529 scoped_ptr<web_modal::NativeWebContentsModalDialogManager>( | 2529 scoped_ptr<web_modal::SingleWebContentsDialogManager>( |
| 2530 native_manager).Pass()); | 2530 native_manager).Pass()); |
| 2531 EXPECT_TRUE(strip_src.IsTabBlocked(1)); | 2531 EXPECT_TRUE(strip_src.IsTabBlocked(1)); |
| 2532 | 2532 |
| 2533 // Detach the tab. | 2533 // Detach the tab. |
| 2534 WebContents* moved_contents = strip_src.DetachWebContentsAt(1); | 2534 WebContents* moved_contents = strip_src.DetachWebContentsAt(1); |
| 2535 EXPECT_EQ(contents2, moved_contents); | 2535 EXPECT_EQ(contents2, moved_contents); |
| 2536 | 2536 |
| 2537 // Attach the tab to the destination tab strip. | 2537 // Attach the tab to the destination tab strip. |
| 2538 strip_dst.AppendWebContents(moved_contents, true); | 2538 strip_dst.AppendWebContents(moved_contents, true); |
| 2539 EXPECT_TRUE(strip_dst.IsTabBlocked(0)); | 2539 EXPECT_TRUE(strip_dst.IsTabBlocked(0)); |
| 2540 | 2540 |
| 2541 strip_dst.CloseAllTabs(); | 2541 strip_dst.CloseAllTabs(); |
| 2542 strip_src.CloseAllTabs(); | 2542 strip_src.CloseAllTabs(); |
| 2543 } | 2543 } |
| OLD | NEW |