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

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

Issue 1982723002: Use FileTypePolicies for download danger classifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@use_policies
Patch Set: Fix bad rebase Created 4 years, 7 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
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 "chrome/browser/download/download_item_model.h" 5 #include "chrome/browser/download/download_item_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
17 #include "base/strings/string_split.h" 17 #include "base/strings/string_split.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
20 #include "content/public/test/mock_download_item.h" 20 #include "content/public/test/mock_download_item.h"
21 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/base/text/bytes_formatting.h" 24 #include "ui/base/text/bytes_formatting.h"
25 #include "ui/gfx/font_list.h" 25 #include "ui/gfx/font_list.h"
26 #include "ui/gfx/text_utils.h" 26 #include "ui/gfx/text_utils.h"
27 27
28 using content::DownloadItem; 28 using content::DownloadItem;
29 using safe_browsing::DownloadFileType;
29 using ::testing::Mock; 30 using ::testing::Mock;
30 using ::testing::NiceMock; 31 using ::testing::NiceMock;
31 using ::testing::Return; 32 using ::testing::Return;
32 using ::testing::ReturnRefOfCopy; 33 using ::testing::ReturnRefOfCopy;
33 using ::testing::SetArgPointee; 34 using ::testing::SetArgPointee;
34 using ::testing::_; 35 using ::testing::_;
35 36
36 namespace { 37 namespace {
37 38
38 // Create a char array that has as many elements as there are download 39 // Create a char array that has as many elements as there are download
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 EXPECT_FALSE(model().ShouldShowInShelf()); 369 EXPECT_FALSE(model().ShouldShowInShelf());
369 370
370 model().SetShouldShowInShelf(true); 371 model().SetShouldShowInShelf(true);
371 EXPECT_TRUE(model().ShouldShowInShelf()); 372 EXPECT_TRUE(model().ShouldShowInShelf());
372 } 373 }
373 374
374 TEST_F(DownloadItemModelTest, DangerLevel) { 375 TEST_F(DownloadItemModelTest, DangerLevel) {
375 SetupDownloadItemDefaults(); 376 SetupDownloadItemDefaults();
376 377
377 // Default danger level is NOT_DANGEROUS. 378 // Default danger level is NOT_DANGEROUS.
378 EXPECT_EQ(download_util::NOT_DANGEROUS, model().GetDangerLevel()); 379 EXPECT_EQ(DownloadFileType::NOT_DANGEROUS, model().GetDangerLevel());
379 380
380 model().SetDangerLevel(download_util::ALLOW_ON_USER_GESTURE); 381 model().SetDangerLevel(DownloadFileType::ALLOW_ON_USER_GESTURE);
381 EXPECT_EQ(download_util::ALLOW_ON_USER_GESTURE, model().GetDangerLevel()); 382 EXPECT_EQ(DownloadFileType::ALLOW_ON_USER_GESTURE, model().GetDangerLevel());
382 } 383 }
383 384
384 TEST_F(DownloadItemModelTest, ShouldRemoveFromShelfWhenComplete) { 385 TEST_F(DownloadItemModelTest, ShouldRemoveFromShelfWhenComplete) {
385 const struct TestCase { 386 const struct TestCase {
386 DownloadItem::DownloadState state; 387 DownloadItem::DownloadState state;
387 bool is_dangerous; // Expectation for IsDangerous(). 388 bool is_dangerous; // Expectation for IsDangerous().
388 bool is_auto_open; // Expectation for GetOpenWhenComplete(). 389 bool is_auto_open; // Expectation for GetOpenWhenComplete().
389 bool auto_opened; // Whether the download was successfully 390 bool auto_opened; // Whether the download was successfully
390 // auto-opened. Expecation for GetAutoOpened(). 391 // auto-opened. Expecation for GetAutoOpened().
391 bool expected_result; 392 bool expected_result;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 EXPECT_CALL(item(), GetAutoOpened()) 429 EXPECT_CALL(item(), GetAutoOpened())
429 .WillRepeatedly(Return(test_case.auto_opened)); 430 .WillRepeatedly(Return(test_case.auto_opened));
430 431
431 EXPECT_EQ(test_case.expected_result, 432 EXPECT_EQ(test_case.expected_result,
432 model().ShouldRemoveFromShelfWhenComplete()) 433 model().ShouldRemoveFromShelfWhenComplete())
433 << "Test case: " << i; 434 << "Test case: " << i;
434 Mock::VerifyAndClearExpectations(&item()); 435 Mock::VerifyAndClearExpectations(&item());
435 Mock::VerifyAndClearExpectations(&model()); 436 Mock::VerifyAndClearExpectations(&model());
436 } 437 }
437 } 438 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/browser/download/download_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698