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

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

Issue 209613002: Download shelf autohides on showing in shell, just same as regular open Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added browser and unit tests. Renamed 'UserActed' to 'OpenedOrShown'. Created 4 years, 1 month 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>
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 EXPECT_CALL(item(), GetAutoOpened()) 457 EXPECT_CALL(item(), GetAutoOpened())
458 .WillRepeatedly(Return(test_case.auto_opened)); 458 .WillRepeatedly(Return(test_case.auto_opened));
459 459
460 EXPECT_EQ(test_case.expected_result, 460 EXPECT_EQ(test_case.expected_result,
461 model().ShouldRemoveFromShelfWhenComplete()) 461 model().ShouldRemoveFromShelfWhenComplete())
462 << "Test case: " << i; 462 << "Test case: " << i;
463 Mock::VerifyAndClearExpectations(&item()); 463 Mock::VerifyAndClearExpectations(&item());
464 Mock::VerifyAndClearExpectations(&model()); 464 Mock::VerifyAndClearExpectations(&model());
465 } 465 }
466 } 466 }
467
468 TEST_F(DownloadItemModelTest, GetSetOpenedOrShown) {
469 SetupDownloadItemDefaults();
470
471 {
472 // Not set by-default.
473 EXPECT_CALL(item(), GetOpened()).WillRepeatedly(Return(false));
474 EXPECT_FALSE(model().GetOpenedOrShown());
475 Mock::VerifyAndClearExpectations(&item());
476 }
477
478 // Otherwise, it returns GetOpened() or GetOpenedOrShown().
479 const struct TestCase {
480 bool opened;
481 bool opened_or_shown;
482 bool expected;
483 } kTestCases[] = {
484 { true, true, true },
485 { true, false, true },
486 { false, true, true },
487 { false, false, false }
488 };
489
490 for (unsigned i = 0; i < arraysize(kTestCases); i++) {
491 const TestCase& test_case = kTestCases[i];
492 EXPECT_CALL(item(), GetOpened()).WillRepeatedly(Return(test_case.opened));
493 model().SetOpenedOrShown(test_case.opened_or_shown);
494 EXPECT_EQ(test_case.expected, model().GetOpenedOrShown())
495 << "Test case: " << i;
496 Mock::VerifyAndClearExpectations(&item());
497 }
498 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/browser/extensions/api/downloads/downloads_api_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698