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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller_browsertest.mm

Issue 409743003: Use content::RunBlockingPoolTask() in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed. Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #import "chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller.h " 5 #import "chrome/browser/ui/cocoa/extensions/windowed_install_dialog_controller.h "
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/threading/sequenced_worker_pool.h" 8 #include "base/threading/sequenced_worker_pool.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #import "chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils. h" 10 #import "chrome/browser/ui/cocoa/extensions/extension_install_prompt_test_utils. h"
11 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h" 11 #import "chrome/browser/ui/cocoa/extensions/extension_install_view_controller.h"
12 #include "chrome/test/base/in_process_browser_test.h" 12 #include "chrome/test/base/in_process_browser_test.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "content/public/test/test_utils.h"
14 #include "extensions/common/extension.h" 15 #include "extensions/common/extension.h"
15 16
16 namespace { 17 namespace {
17 18
18 // Similar to ShowExtensionInstallDialogImpl except this allows the created 19 // Similar to ShowExtensionInstallDialogImpl except this allows the created
19 // dialog controller to be captured and manipulated for tests. 20 // dialog controller to be captured and manipulated for tests.
20 void TestingShowAppListInstallDialogController( 21 void TestingShowAppListInstallDialogController(
21 WindowedInstallDialogController** controller, 22 WindowedInstallDialogController** controller,
22 const ExtensionInstallPrompt::ShowParams& show_params, 23 const ExtensionInstallPrompt::ShowParams& show_params,
23 ExtensionInstallPrompt::Delegate* delegate, 24 ExtensionInstallPrompt::Delegate* delegate,
(...skipping 17 matching lines...) Expand all
41 WindowedInstallDialogController* controller = NULL; 42 WindowedInstallDialogController* controller = NULL;
42 chrome::MockExtensionInstallPromptDelegate delegate; 43 chrome::MockExtensionInstallPromptDelegate delegate;
43 scoped_refptr<extensions::Extension> extension = 44 scoped_refptr<extensions::Extension> extension =
44 chrome::LoadInstallPromptExtension("permissions", "many-apis.json"); 45 chrome::LoadInstallPromptExtension("permissions", "many-apis.json");
45 prompt->ConfirmInstall( 46 prompt->ConfirmInstall(
46 &delegate, 47 &delegate,
47 extension.get(), 48 extension.get(),
48 base::Bind(&TestingShowAppListInstallDialogController, &controller)); 49 base::Bind(&TestingShowAppListInstallDialogController, &controller));
49 50
50 // The prompt needs to load the image, which happens on the blocking pool. 51 // The prompt needs to load the image, which happens on the blocking pool.
51 content::BrowserThread::GetBlockingPool()->FlushForTesting(); 52 content::RunAllBlockingPoolTasksUntilIdle();
52 base::RunLoop().RunUntilIdle();
53 ASSERT_TRUE(controller); 53 ASSERT_TRUE(controller);
54 54
55 base::scoped_nsobject<NSWindow> window( 55 base::scoped_nsobject<NSWindow> window(
56 [[[controller->GetViewController() view] window] retain]); 56 [[[controller->GetViewController() view] window] retain]);
57 EXPECT_TRUE([window isVisible]); 57 EXPECT_TRUE([window isVisible]);
58 EXPECT_TRUE([window delegate]); 58 EXPECT_TRUE([window delegate]);
59 EXPECT_EQ(0, delegate.abort_count()); 59 EXPECT_EQ(0, delegate.abort_count());
60 60
61 // Press cancel to close the window. 61 // Press cancel to close the window.
62 [[controller->GetViewController() cancelButton] performClick:nil]; 62 [[controller->GetViewController() cancelButton] performClick:nil];
63 EXPECT_FALSE([window delegate]); 63 EXPECT_FALSE([window delegate]);
64 EXPECT_EQ(1, delegate.abort_count()); 64 EXPECT_EQ(1, delegate.abort_count());
65 65
66 // Ensure the window is closed. 66 // Ensure the window is closed.
67 EXPECT_FALSE([window isVisible]); 67 EXPECT_FALSE([window isVisible]);
68 } 68 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698