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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view_browsertest.cc

Issue 2551773002: MacViews: Exploring removal of window-modal sheets.
Patch Set: Created 4 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/command_line.h"
5 #include "base/macros.h" 6 #include "base/macros.h"
6 #include "base/run_loop.h" 7 #include "base/run_loop.h"
7 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 9 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
9 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
11 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
12 #include "content/public/test/test_utils.h" 13 #include "content/public/test/test_utils.h"
13 #include "extensions/browser/extension_system.h" 14 #include "extensions/browser/extension_system.h"
14 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
15 #include "extensions/common/extension_builder.h" 16 #include "extensions/common/extension_builder.h"
16 #include "extensions/common/value_builder.h" 17 #include "extensions/common/value_builder.h"
17 18 #include "ui/base/ui_base_switches.h"
18 #if defined(OS_MACOSX) 19 #include "ui/views/widget/widget.h"
19 #include "base/command_line.h"
20 #include "chrome/browser/ui/browser_dialogs.h"
21 #include "content/public/common/content_switches.h"
22 #endif
23 20
24 namespace { 21 namespace {
25 22
26 scoped_refptr<extensions::Extension> BuildTestExtension() { 23 scoped_refptr<extensions::Extension> BuildTestExtension() {
27 return extensions::ExtensionBuilder() 24 return extensions::ExtensionBuilder()
28 .SetManifest(extensions::DictionaryBuilder() 25 .SetManifest(extensions::DictionaryBuilder()
29 .Set("name", "foo") 26 .Set("name", "foo")
30 .Set("version", "1.0") 27 .Set("version", "1.0")
31 .Build()) 28 .Build())
32 .Build(); 29 .Build();
(...skipping 18 matching lines...) Expand all
51 } 48 }
52 49
53 base::Closure quit_closure_; 50 base::Closure quit_closure_;
54 bool canceled_; 51 bool canceled_;
55 52
56 DISALLOW_COPY_AND_ASSIGN(TestExtensionUninstallDialogDelegate); 53 DISALLOW_COPY_AND_ASSIGN(TestExtensionUninstallDialogDelegate);
57 }; 54 };
58 55
59 } // namespace 56 } // namespace
60 57
61 typedef InProcessBrowserTest ExtensionUninstallDialogViewBrowserTest; 58 class ExtensionUninstallDialogViewBrowserTest : public InProcessBrowserTest {
59 public:
60 ExtensionUninstallDialogViewBrowserTest() {}
62 61
63 // Test that ExtensionUninstallDialog cancels the uninstall if the aura::Window 62 // InProcessBrowserTest:
64 // which is passed to ExtensionUninstallDialog::Create() is destroyed before 63 void SetUpCommandLine(base::CommandLine* command_line) override {
64 #if defined(OS_MACOSX)
65 base::CommandLine::ForCurrentProcess()->AppendSwitch(
66 switches::kExtendMdToSecondaryUi);
67 #endif
68 }
69
70 private:
71 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogViewBrowserTest);
72 };
73
74 // Test that ExtensionUninstallDialog cancels the uninstall if the Window which
75 // is passed to ExtensionUninstallDialog::Create() is destroyed before
65 // ExtensionUninstallDialogDelegateView is created. 76 // ExtensionUninstallDialogDelegateView is created.
66 IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, 77 IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest,
67 TrackParentWindowDestruction) { 78 TrackParentWindowDestruction) {
68 #if defined(OS_MACOSX)
69 base::CommandLine::ForCurrentProcess()->
70 AppendSwitchASCII(switches::kEnableFeatures,
71 chrome::kMacViewsWebUIDialogs.name);
72 #endif
73
74 scoped_refptr<extensions::Extension> extension(BuildTestExtension()); 79 scoped_refptr<extensions::Extension> extension(BuildTestExtension());
75 extensions::ExtensionSystem::Get(browser()->profile())->extension_service() 80 extensions::ExtensionSystem::Get(browser()->profile())->extension_service()
76 ->AddExtension(extension.get()); 81 ->AddExtension(extension.get());
77 82
78 base::RunLoop run_loop; 83 base::RunLoop run_loop;
79 TestExtensionUninstallDialogDelegate delegate(run_loop.QuitClosure()); 84 TestExtensionUninstallDialogDelegate delegate(run_loop.QuitClosure());
80 std::unique_ptr<extensions::ExtensionUninstallDialog> dialog( 85 std::unique_ptr<extensions::ExtensionUninstallDialog> dialog(
81 extensions::ExtensionUninstallDialog::Create( 86 extensions::ExtensionUninstallDialog::Create(
82 browser()->profile(), browser()->window()->GetNativeWindow(), 87 browser()->profile(), browser()->window()->GetNativeWindow(),
83 &delegate)); 88 &delegate));
84 browser()->window()->Close(); 89 browser()->window()->Close();
85 content::RunAllPendingInMessageLoop(); 90 content::RunAllPendingInMessageLoop();
86 91
87 dialog->ConfirmUninstall(extension.get(), 92 dialog->ConfirmUninstall(extension.get(),
88 extensions::UNINSTALL_REASON_FOR_TESTING, 93 extensions::UNINSTALL_REASON_FOR_TESTING,
89 extensions::UNINSTALL_SOURCE_FOR_TESTING); 94 extensions::UNINSTALL_SOURCE_FOR_TESTING);
90 run_loop.Run(); 95 run_loop.Run();
91 EXPECT_TRUE(delegate.canceled()); 96 EXPECT_TRUE(delegate.canceled());
92 } 97 }
93 98
94 // Test that ExtensionUninstallDialog cancels the uninstall if the aura::Window 99 // Test that ExtensionUninstallDialog cancels the uninstall if the Window which
95 // which is passed to ExtensionUninstallDialog::Create() is destroyed after 100 // is passed to ExtensionUninstallDialog::Create() is destroyed after
96 // ExtensionUninstallDialogDelegateView is created. 101 // ExtensionUninstallDialogDelegateView is created.
97 IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest, 102 IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest,
98 TrackParentWindowDestructionAfterViewCreation) { 103 TrackParentWindowDestructionAfterViewCreation) {
99 #if defined(OS_MACOSX)
100 base::CommandLine::ForCurrentProcess()->
101 AppendSwitchASCII(switches::kEnableFeatures,
102 chrome::kMacViewsWebUIDialogs.name);
103 #endif
104
105 scoped_refptr<extensions::Extension> extension(BuildTestExtension()); 104 scoped_refptr<extensions::Extension> extension(BuildTestExtension());
106 extensions::ExtensionSystem::Get(browser()->profile())->extension_service() 105 extensions::ExtensionSystem::Get(browser()->profile())->extension_service()
107 ->AddExtension(extension.get()); 106 ->AddExtension(extension.get());
108 107
109 base::RunLoop run_loop; 108 base::RunLoop run_loop;
110 TestExtensionUninstallDialogDelegate delegate(run_loop.QuitClosure()); 109 TestExtensionUninstallDialogDelegate delegate(run_loop.QuitClosure());
111 std::unique_ptr<extensions::ExtensionUninstallDialog> dialog( 110 std::unique_ptr<extensions::ExtensionUninstallDialog> dialog(
112 extensions::ExtensionUninstallDialog::Create( 111 extensions::ExtensionUninstallDialog::Create(
113 browser()->profile(), browser()->window()->GetNativeWindow(), 112 browser()->profile(), browser()->window()->GetNativeWindow(),
114 &delegate)); 113 &delegate));
115 content::RunAllPendingInMessageLoop(); 114 content::RunAllPendingInMessageLoop();
116 115
117 dialog->ConfirmUninstall(extension.get(), 116 dialog->ConfirmUninstall(extension.get(),
118 extensions::UNINSTALL_REASON_FOR_TESTING, 117 extensions::UNINSTALL_REASON_FOR_TESTING,
119 extensions::UNINSTALL_SOURCE_FOR_TESTING); 118 extensions::UNINSTALL_SOURCE_FOR_TESTING);
120 119
121 content::RunAllPendingInMessageLoop(); 120 content::RunAllPendingInMessageLoop();
122 121
123 // Kill parent window. 122 // Kill parent window.
123 base::RunLoop().Run();
124 browser()->window()->Close(); 124 browser()->window()->Close();
125 run_loop.Run(); 125 run_loop.Run();
126 EXPECT_TRUE(delegate.canceled()); 126 EXPECT_TRUE(delegate.canceled());
127 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698