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

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

Issue 697023002: Cancel uninstall if the uninstall dialog's parent window is destroyed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/run_loop.h"
6 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_window.h"
9 #include "chrome/test/base/in_process_browser_test.h"
10 #include "content/public/test/test_utils.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/common/extension_builder.h"
13 #include "extensions/common/value_builder.h"
14
15 namespace {
16
17 scoped_refptr<extensions::Extension> BuildTestExtension() {
18 return extensions::ExtensionBuilder()
19 .SetManifest(extensions::DictionaryBuilder()
20 .Set("name", "foo")
21 .Set("version", "1.0"))
22 .Build();
23 }
24
25 class TestExtensionUninstallDialogDelegate
26 : public extensions::ExtensionUninstallDialog::Delegate {
27 public:
28 explicit TestExtensionUninstallDialogDelegate(
29 const base::Closure& quit_closure)
30 : quit_closure_(quit_closure), canceled_(false) {}
31
32 ~TestExtensionUninstallDialogDelegate() override {}
33
34 bool canceled() { return canceled_; }
35
36 private:
37 void ExtensionUninstallAccepted() override { quit_closure_.Run(); }
38
39 void ExtensionUninstallCanceled() override {
40 canceled_ = true;
41 quit_closure_.Run();
42 }
43
44 base::Closure quit_closure_;
45 bool canceled_;
46
47 DISALLOW_COPY_AND_ASSIGN(TestExtensionUninstallDialogDelegate);
48 };
49
50 } // namespace
51
52 typedef InProcessBrowserTest ExtensionUninstallDialogViewBrowserTest;
53
54 // Test that ExtensionUninstallDialog cancels the uninstall if the aura::Window
55 // which is passed to ExtensionUninstallDialog::Create() is destroyed.
56 IN_PROC_BROWSER_TEST_F(ExtensionUninstallDialogViewBrowserTest,
57 TrackParentWindowDestruction) {
58 // Create a second browser to prevent the app from exiting when the browser is
59 // closed.
60 CreateBrowser(browser()->profile());
61
62 scoped_refptr<extensions::Extension> extension(BuildTestExtension());
63
64 base::RunLoop run_loop;
65 TestExtensionUninstallDialogDelegate delegate(run_loop.QuitClosure());
66 scoped_ptr<extensions::ExtensionUninstallDialog> dialog(
67 extensions::ExtensionUninstallDialog::Create(
68 browser()->profile(), browser()->window()->GetNativeWindow(),
69 &delegate));
70 browser()->window()->Close();
71 content::RunAllPendingInMessageLoop();
72
73 dialog->ConfirmUninstall(extension.get());
74 run_loop.Run();
75 EXPECT_TRUE(delegate.canceled());
76 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698