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

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

Issue 16007017: [Resumption 10/12] Use DI::IsDone to check for terminal downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r204343 Created 7 years, 6 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/files/file_path.h" 6 #include "base/files/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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // The Accept action should cause the accept callback to be invoked. 115 // The Accept action should cause the accept callback to be invoked.
116 SetUpExpectations(DownloadDangerPrompt::ACCEPT); 116 SetUpExpectations(DownloadDangerPrompt::ACCEPT);
117 SimulatePromptAction(DownloadDangerPrompt::ACCEPT); 117 SimulatePromptAction(DownloadDangerPrompt::ACCEPT);
118 VerifyExpectations(); 118 VerifyExpectations();
119 119
120 // The Discard action should cause the discard callback to be invoked. 120 // The Discard action should cause the discard callback to be invoked.
121 SetUpExpectations(DownloadDangerPrompt::CANCEL); 121 SetUpExpectations(DownloadDangerPrompt::CANCEL);
122 SimulatePromptAction(DownloadDangerPrompt::CANCEL); 122 SimulatePromptAction(DownloadDangerPrompt::CANCEL);
123 VerifyExpectations(); 123 VerifyExpectations();
124 124
125 // If the download is no longer in-progress, the dialog should dismiss itself.
126 SetUpExpectations(DownloadDangerPrompt::CANCEL);
127 EXPECT_CALL(download(), GetState()).WillOnce(
128 Return(content::DownloadItem::CANCELLED));
129 download_observer()->OnDownloadUpdated(&download());
130 VerifyExpectations();
131
132 // If the download is no longer dangerous (because it was accepted), the 125 // If the download is no longer dangerous (because it was accepted), the
133 // dialog should dismiss itself. 126 // dialog should dismiss itself.
134 SetUpExpectations(DownloadDangerPrompt::CANCEL); 127 SetUpExpectations(DownloadDangerPrompt::CANCEL);
135 EXPECT_CALL(download(), GetState()).WillOnce(
136 Return(content::DownloadItem::IN_PROGRESS));
137 EXPECT_CALL(download(), IsDangerous()).WillOnce(Return(false)); 128 EXPECT_CALL(download(), IsDangerous()).WillOnce(Return(false));
138 download_observer()->OnDownloadUpdated(&download()); 129 download_observer()->OnDownloadUpdated(&download());
139 VerifyExpectations(); 130 VerifyExpectations();
140 131
132 // If the download is in a terminal state then the dialog should dismiss
133 // itself.
134 SetUpExpectations(DownloadDangerPrompt::CANCEL);
135 EXPECT_CALL(download(), IsDangerous()).WillOnce(Return(true));
136 EXPECT_CALL(download(), IsDone()).WillOnce(Return(true));
137 download_observer()->OnDownloadUpdated(&download());
138 VerifyExpectations();
139
140 // If the download is dangerous and is not in a terminal state, don't dismiss
141 // the dialog.
142 SetUpExpectations(DownloadDangerPrompt::ACCEPT);
143 EXPECT_CALL(download(), IsDangerous()).WillOnce(Return(true));
144 EXPECT_CALL(download(), IsDone()).WillOnce(Return(false));
145 download_observer()->OnDownloadUpdated(&download());
146 SimulatePromptAction(DownloadDangerPrompt::ACCEPT);
147 VerifyExpectations();
148
141 // If the containing tab is closed, the dialog should be canceled. 149 // If the containing tab is closed, the dialog should be canceled.
142 OpenNewTab(); 150 OpenNewTab();
143 SetUpExpectations(DownloadDangerPrompt::CANCEL); 151 SetUpExpectations(DownloadDangerPrompt::CANCEL);
144 chrome::CloseTab(browser()); 152 chrome::CloseTab(browser());
145 VerifyExpectations(); 153 VerifyExpectations();
146 } 154 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_danger_prompt.cc ('k') | chrome/browser/download/download_shelf_context_menu.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698