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

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

Issue 985133002: Remove NativeWebContentsModalDialog and NativePopup typedefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extension-popup
Patch Set: Created 5 years, 9 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
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 21 matching lines...) Expand all
32 #include "content/public/browser/navigation_entry.h" 32 #include "content/public/browser/navigation_entry.h"
33 #include "content/public/browser/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
34 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
35 #include "content/public/browser/web_contents_observer.h" 35 #include "content/public/browser/web_contents_observer.h"
36 #include "extensions/common/extension.h" 36 #include "extensions/common/extension.h"
37 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
38 38
39 using content::SiteInstance; 39 using content::SiteInstance;
40 using content::WebContents; 40 using content::WebContents;
41 using extensions::Extension; 41 using extensions::Extension;
42 using web_modal::NativeWebContentsModalDialog;
43 42
44 namespace { 43 namespace {
45 44
46 // Class used to delete a WebContents and TabStripModel when another WebContents 45 // Class used to delete a WebContents and TabStripModel when another WebContents
47 // is destroyed. 46 // is destroyed.
48 class DeleteWebContentsOnDestroyedObserver 47 class DeleteWebContentsOnDestroyedObserver
49 : public content::WebContentsObserver { 48 : public content::WebContentsObserver {
50 public: 49 public:
51 // When |source| is deleted both |tab_to_delete| and |tab_strip| are deleted. 50 // When |source| is deleted both |tab_to_delete| and |tab_strip| are deleted.
52 // |tab_to_delete| and |tab_strip| may be NULL. 51 // |tab_to_delete| and |tab_strip| may be NULL.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 int id() { return id_; } 100 int id() { return id_; }
102 101
103 private: 102 private:
104 int id_; 103 int id_;
105 }; 104 };
106 105
107 class DummySingleWebContentsDialogManager 106 class DummySingleWebContentsDialogManager
108 : public web_modal::SingleWebContentsDialogManager { 107 : public web_modal::SingleWebContentsDialogManager {
109 public: 108 public:
110 explicit DummySingleWebContentsDialogManager( 109 explicit DummySingleWebContentsDialogManager(
111 NativeWebContentsModalDialog dialog, 110 gfx::NativeWindow dialog,
112 web_modal::SingleWebContentsDialogManagerDelegate* delegate) 111 web_modal::SingleWebContentsDialogManagerDelegate* delegate)
113 : delegate_(delegate), 112 : delegate_(delegate),
114 dialog_(dialog) {} 113 dialog_(dialog) {}
115 ~DummySingleWebContentsDialogManager() override {} 114 ~DummySingleWebContentsDialogManager() override {}
116 115
117 void Show() override {} 116 void Show() override {}
118 void Hide() override {} 117 void Hide() override {}
119 void Close() override { delegate_->WillClose(dialog_); } 118 void Close() override { delegate_->WillClose(dialog_); }
120 void Focus() override {} 119 void Focus() override {}
121 void Pulse() override {} 120 void Pulse() override {}
122 void HostChanged(web_modal::WebContentsModalDialogHost* new_host) override {} 121 void HostChanged(web_modal::WebContentsModalDialogHost* new_host) override {}
123 NativeWebContentsModalDialog dialog() override { return dialog_; } 122 gfx::NativeWindow dialog() override { return dialog_; }
124 123
125 private: 124 private:
126 web_modal::SingleWebContentsDialogManagerDelegate* delegate_; 125 web_modal::SingleWebContentsDialogManagerDelegate* delegate_;
127 NativeWebContentsModalDialog dialog_; 126 gfx::NativeWindow dialog_;
128 127
129 DISALLOW_COPY_AND_ASSIGN(DummySingleWebContentsDialogManager); 128 DISALLOW_COPY_AND_ASSIGN(DummySingleWebContentsDialogManager);
130 }; 129 };
131 130
132 // Test Browser-like class for TabStripModelTest.TabBlockedState. 131 // Test Browser-like class for TabStripModelTest.TabBlockedState.
133 class TabBlockedStateTestBrowser 132 class TabBlockedStateTestBrowser
134 : public TabStripModelObserver, 133 : public TabStripModelObserver,
135 public web_modal::WebContentsModalDialogManagerDelegate { 134 public web_modal::WebContentsModalDialogManagerDelegate {
136 public: 135 public:
137 explicit TabBlockedStateTestBrowser(TabStripModel* tab_strip_model) 136 explicit TabBlockedStateTestBrowser(TabStripModel* tab_strip_model)
(...skipping 2523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2661 TabBlockedStateTestBrowser browser_dst(&strip_dst); 2660 TabBlockedStateTestBrowser browser_dst(&strip_dst);
2662 2661
2663 // Setup a SingleWebContentsDialogManager for tab |contents2|. 2662 // Setup a SingleWebContentsDialogManager for tab |contents2|.
2664 web_modal::WebContentsModalDialogManager* modal_dialog_manager = 2663 web_modal::WebContentsModalDialogManager* modal_dialog_manager =
2665 web_modal::WebContentsModalDialogManager::FromWebContents(contents2); 2664 web_modal::WebContentsModalDialogManager::FromWebContents(contents2);
2666 web_modal::PopupManager popup_manager(NULL); 2665 web_modal::PopupManager popup_manager(NULL);
2667 popup_manager.RegisterWith(contents2); 2666 popup_manager.RegisterWith(contents2);
2668 2667
2669 // Show a dialog that blocks tab |contents2|. 2668 // Show a dialog that blocks tab |contents2|.
2670 // DummySingleWebContentsDialogManager doesn't care about the 2669 // DummySingleWebContentsDialogManager doesn't care about the
2671 // NativeWebContentsModalDialog value, so any dummy value works. 2670 // dialog window value, so any dummy value works.
2672 DummySingleWebContentsDialogManager* native_manager = 2671 DummySingleWebContentsDialogManager* native_manager =
2673 new DummySingleWebContentsDialogManager( 2672 new DummySingleWebContentsDialogManager(
2674 reinterpret_cast<NativeWebContentsModalDialog>(0), 2673 reinterpret_cast<gfx::NativeWindow>(0), modal_dialog_manager);
2675 modal_dialog_manager);
2676 modal_dialog_manager->ShowDialogWithManager( 2674 modal_dialog_manager->ShowDialogWithManager(
2677 reinterpret_cast<NativeWebContentsModalDialog>(0), 2675 reinterpret_cast<gfx::NativeWindow>(0),
2678 scoped_ptr<web_modal::SingleWebContentsDialogManager>( 2676 scoped_ptr<web_modal::SingleWebContentsDialogManager>(
2679 native_manager).Pass()); 2677 native_manager).Pass());
2680 EXPECT_TRUE(strip_src.IsTabBlocked(1)); 2678 EXPECT_TRUE(strip_src.IsTabBlocked(1));
2681 2679
2682 // Detach the tab. 2680 // Detach the tab.
2683 WebContents* moved_contents = strip_src.DetachWebContentsAt(1); 2681 WebContents* moved_contents = strip_src.DetachWebContentsAt(1);
2684 EXPECT_EQ(contents2, moved_contents); 2682 EXPECT_EQ(contents2, moved_contents);
2685 2683
2686 // Attach the tab to the destination tab strip. 2684 // Attach the tab to the destination tab strip.
2687 strip_dst.AppendWebContents(moved_contents, true); 2685 strip_dst.AppendWebContents(moved_contents, true);
2688 EXPECT_TRUE(strip_dst.IsTabBlocked(0)); 2686 EXPECT_TRUE(strip_dst.IsTabBlocked(0));
2689 2687
2690 strip_dst.CloseAllTabs(); 2688 strip_dst.CloseAllTabs();
2691 strip_src.CloseAllTabs(); 2689 strip_src.CloseAllTabs();
2692 } 2690 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698