Commit 839a47ea authored by Sergey Poromov's avatar Sergey Poromov Committed by Commit Bot

Add unit test for deep scanning in Chrome OS download notification.

Original CL: https://crrev.com/c/2127707

Bug: 1062788
Change-Id: Ife67de34bd4b214a6832bd9889ac050fc056f2be
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132129Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Commit-Queue: Sergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755439}
parent 3def15c0
......@@ -12,6 +12,7 @@
#include "base/run_loop.h"
#include "base/test/test_simple_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/notification/download_notification_manager.h"
#include "chrome/browser/download/offline_item_utils.h"
#include "chrome/browser/notifications/notification_display_service.h"
......@@ -261,4 +262,58 @@ TEST_F(DownloadItemNotificationTest, DisablePopup) {
EXPECT_GT(LookUpNotification()->priority(), message_center::LOW_PRIORITY);
}
TEST_F(DownloadItemNotificationTest, DeepScanning) {
// Setup deep scanning in progress.
EXPECT_CALL(*download_item_, GetDangerType())
.WillRepeatedly(Return(download::DOWNLOAD_DANGER_TYPE_ASYNC_SCANNING));
auto state =
std::make_unique<ChromeDownloadManagerDelegate::SafeBrowsingState>();
download_item_->SetUserData(&ChromeDownloadManagerDelegate::
SafeBrowsingState::kSafeBrowsingUserDataKey,
std::move(state));
CreateDownloadItemNotification();
// Can't open while scanning.
profile_manager_->local_state()->Get()->SetManagedPref(
prefs::kDelayDeliveryUntilVerdict,
std::make_unique<base::Value>(safe_browsing::DELAY_DOWNLOADS));
EXPECT_CALL(*download_item_, OpenDownload()).Times(0);
EXPECT_CALL(*download_item_, SetOpenWhenComplete(true)).Times(1);
download_item_notification_->Click(base::nullopt, base::nullopt);
// Can be opened while scanning.
profile_manager_->local_state()->Get()->SetManagedPref(
prefs::kDelayDeliveryUntilVerdict,
std::make_unique<base::Value>(safe_browsing::DELAY_NONE));
EXPECT_CALL(*download_item_, OpenDownload()).Times(1);
download_item_notification_->Click(base::nullopt, base::nullopt);
// Scanning finished, warning.
EXPECT_CALL(*download_item_, IsDangerous()).WillRepeatedly(Return(true));
EXPECT_CALL(*download_item_, GetDangerType())
.WillRepeatedly(
Return(download::DOWNLOAD_DANGER_TYPE_SENSITIVE_CONTENT_WARNING));
EXPECT_CALL(*download_item_, OpenDownload()).Times(0);
EXPECT_CALL(*download_item_, SetOpenWhenComplete(true)).Times(0);
download_item_notification_->Click(base::nullopt, base::nullopt);
// Scanning finished, blocked.
EXPECT_CALL(*download_item_, IsDangerous()).WillRepeatedly(Return(true));
EXPECT_CALL(*download_item_, GetDangerType())
.WillRepeatedly(
Return(download::DOWNLOAD_DANGER_TYPE_SENSITIVE_CONTENT_BLOCK));
EXPECT_CALL(*download_item_, OpenDownload()).Times(0);
EXPECT_CALL(*download_item_, SetOpenWhenComplete(true)).Times(0);
download_item_notification_->Click(base::nullopt, base::nullopt);
// Scanning finished, safe.
EXPECT_CALL(*download_item_, IsDangerous()).WillRepeatedly(Return(false));
EXPECT_CALL(*download_item_, GetDangerType())
.WillRepeatedly(Return(download::DOWNLOAD_DANGER_TYPE_DEEP_SCANNED_SAFE));
EXPECT_CALL(*download_item_, GetState())
.WillRepeatedly(Return(download::DownloadItem::COMPLETE));
EXPECT_CALL(*download_item_, OpenDownload()).Times(1);
download_item_notification_->Click(base::nullopt, base::nullopt);
}
} // namespace test
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment