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

Side by Side Diff: chrome/browser/download/download_danger_prompt_browsertest.cc

Issue 10825085: Move RunAllPendingInMessageLoop from ui_test_utils.h to test_utils.h, so that it can be reused by c… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 (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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "chrome/browser/download/download_danger_prompt.h" 7 #include "chrome/browser/download/download_danger_prompt.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_commands.h" 9 #include "chrome/browser/ui/browser_commands.h"
10 #include "chrome/browser/ui/browser_tabstrip.h" 10 #include "chrome/browser/ui/browser_tabstrip.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 void SetUpExpectations(DownloadDangerPrompt::Action expected_action) { 47 void SetUpExpectations(DownloadDangerPrompt::Action expected_action) {
48 did_receive_callback_ = false; 48 did_receive_callback_ = false;
49 expected_action_ = expected_action; 49 expected_action_ = expected_action;
50 SetUpDownloadItemExpectations(); 50 SetUpDownloadItemExpectations();
51 CreatePrompt(); 51 CreatePrompt();
52 } 52 }
53 53
54 void VerifyExpectations() { 54 void VerifyExpectations() {
55 ui_test_utils::RunAllPendingInMessageLoop(); 55 content::RunAllPendingInMessageLoop();
56 // At the end of each test, we expect no more activity from the prompt. The 56 // At the end of each test, we expect no more activity from the prompt. The
57 // prompt shouldn't exist anymore either. 57 // prompt shouldn't exist anymore either.
58 EXPECT_TRUE(did_receive_callback_); 58 EXPECT_TRUE(did_receive_callback_);
59 EXPECT_FALSE(prompt_); 59 EXPECT_FALSE(prompt_);
60 testing::Mock::VerifyAndClearExpectations(&download_); 60 testing::Mock::VerifyAndClearExpectations(&download_);
61 } 61 }
62 62
63 void SimulatePromptAction(DownloadDangerPrompt::Action action) { 63 void SimulatePromptAction(DownloadDangerPrompt::Action action) {
64 prompt_->InvokeActionForTesting(action); 64 prompt_->InvokeActionForTesting(action);
65 } 65 }
(...skipping 16 matching lines...) Expand all
82 } 82 }
83 83
84 void CreatePrompt() { 84 void CreatePrompt() {
85 prompt_ = DownloadDangerPrompt::Create( 85 prompt_ = DownloadDangerPrompt::Create(
86 &download_, 86 &download_,
87 chrome::GetActiveTabContents(browser()), 87 chrome::GetActiveTabContents(browser()),
88 base::Bind(&DownloadDangerPromptTest::PromptCallback, this, 88 base::Bind(&DownloadDangerPromptTest::PromptCallback, this,
89 DownloadDangerPrompt::ACCEPT), 89 DownloadDangerPrompt::ACCEPT),
90 base::Bind(&DownloadDangerPromptTest::PromptCallback, this, 90 base::Bind(&DownloadDangerPromptTest::PromptCallback, this,
91 DownloadDangerPrompt::CANCEL)); 91 DownloadDangerPrompt::CANCEL));
92 ui_test_utils::RunAllPendingInMessageLoop(); 92 content::RunAllPendingInMessageLoop();
93 } 93 }
94 94
95 void PromptCallback(DownloadDangerPrompt::Action action) { 95 void PromptCallback(DownloadDangerPrompt::Action action) {
96 EXPECT_FALSE(did_receive_callback_); 96 EXPECT_FALSE(did_receive_callback_);
97 EXPECT_EQ(expected_action_, action); 97 EXPECT_EQ(expected_action_, action);
98 did_receive_callback_ = true; 98 did_receive_callback_ = true;
99 prompt_ = NULL; 99 prompt_ = NULL;
100 } 100 }
101 101
102 content::MockDownloadItem download_; 102 content::MockDownloadItem download_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 EXPECT_CALL(download(), IsDangerous()).WillOnce(Return(false)); 134 EXPECT_CALL(download(), IsDangerous()).WillOnce(Return(false));
135 download_observer()->OnDownloadUpdated(&download()); 135 download_observer()->OnDownloadUpdated(&download());
136 VerifyExpectations(); 136 VerifyExpectations();
137 137
138 // If the containing tab is closed, the dialog should be canceled. 138 // If the containing tab is closed, the dialog should be canceled.
139 OpenNewTab(); 139 OpenNewTab();
140 SetUpExpectations(DownloadDangerPrompt::CANCEL); 140 SetUpExpectations(DownloadDangerPrompt::CANCEL);
141 chrome::CloseTab(browser()); 141 chrome::CloseTab(browser());
142 VerifyExpectations(); 142 VerifyExpectations();
143 } 143 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_browsertest.cc ('k') | chrome/browser/extensions/api/declarative/declarative_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698