| OLD | NEW |
| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 .WillByDefault(Return(download_item_.get())); | 87 .WillByDefault(Return(download_item_.get())); |
| 88 ON_CALL(*download_manager_, GetBrowserContext()) | 88 ON_CALL(*download_manager_, GetBrowserContext()) |
| 89 .WillByDefault(Return(profile())); | 89 .WillByDefault(Return(profile())); |
| 90 | 90 |
| 91 shelf_.set_download_manager(download_manager_.get()); | 91 shelf_.set_download_manager(download_manager_.get()); |
| 92 } | 92 } |
| 93 | 93 |
| 94 } // namespace | 94 } // namespace |
| 95 | 95 |
| 96 TEST_F(DownloadShelfTest, ClosesShelfWhenHidden) { | 96 TEST_F(DownloadShelfTest, ClosesShelfWhenHidden) { |
| 97 shelf()->Show(); | 97 shelf()->Open(); |
| 98 EXPECT_TRUE(shelf()->IsShowing()); | 98 EXPECT_TRUE(shelf()->IsShowing()); |
| 99 shelf()->Hide(); | 99 shelf()->Hide(); |
| 100 EXPECT_FALSE(shelf()->IsShowing()); | 100 EXPECT_FALSE(shelf()->IsShowing()); |
| 101 shelf()->Unhide(); | 101 shelf()->Unhide(); |
| 102 EXPECT_TRUE(shelf()->IsShowing()); | 102 EXPECT_TRUE(shelf()->IsShowing()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 TEST_F(DownloadShelfTest, CloseWhileHiddenPreventsShowOnUnhide) { | 105 TEST_F(DownloadShelfTest, CloseWhileHiddenPreventsShowOnUnhide) { |
| 106 shelf()->Show(); | 106 shelf()->Open(); |
| 107 shelf()->Hide(); | 107 shelf()->Hide(); |
| 108 shelf()->Close(DownloadShelf::AUTOMATIC); | 108 shelf()->Close(DownloadShelf::AUTOMATIC); |
| 109 shelf()->Unhide(); | 109 shelf()->Unhide(); |
| 110 EXPECT_FALSE(shelf()->IsShowing()); | 110 EXPECT_FALSE(shelf()->IsShowing()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 TEST_F(DownloadShelfTest, UnhideDoesntShowIfNotShownOnHide) { | 113 TEST_F(DownloadShelfTest, UnhideDoesntShowIfNotShownOnHide) { |
| 114 shelf()->Hide(); | 114 shelf()->Hide(); |
| 115 shelf()->Unhide(); | 115 shelf()->Unhide(); |
| 116 EXPECT_FALSE(shelf()->IsShowing()); | 116 EXPECT_FALSE(shelf()->IsShowing()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 TEST_F(DownloadShelfTest, AddDownloadWhileHiddenUnhides) { | 119 TEST_F(DownloadShelfTest, AddDownloadWhileHiddenUnhides) { |
| 120 shelf()->Show(); | 120 shelf()->Open(); |
| 121 shelf()->Hide(); | 121 shelf()->Hide(); |
| 122 shelf()->AddDownload(download_item()); | 122 shelf()->AddDownload(download_item()); |
| 123 EXPECT_TRUE(shelf()->IsShowing()); | 123 EXPECT_TRUE(shelf()->IsShowing()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 TEST_F(DownloadShelfTest, AddDownloadWhileHiddenUnhidesAndShows) { | 126 TEST_F(DownloadShelfTest, AddDownloadWhileHiddenUnhidesAndShows) { |
| 127 shelf()->Hide(); | 127 shelf()->Hide(); |
| 128 shelf()->AddDownload(download_item()); | 128 shelf()->AddDownload(download_item()); |
| 129 EXPECT_TRUE(shelf()->IsShowing()); | 129 EXPECT_TRUE(shelf()->IsShowing()); |
| 130 } | 130 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 .WillRepeatedly(Return(false)); | 199 .WillRepeatedly(Return(false)); |
| 200 ASSERT_FALSE(DownloadItemModel(download_item()) | 200 ASSERT_FALSE(DownloadItemModel(download_item()) |
| 201 .ShouldRemoveFromShelfWhenComplete()); | 201 .ShouldRemoveFromShelfWhenComplete()); |
| 202 | 202 |
| 203 base::RunLoop run_loop; | 203 base::RunLoop run_loop; |
| 204 run_loop.RunUntilIdle(); | 204 run_loop.RunUntilIdle(); |
| 205 | 205 |
| 206 EXPECT_TRUE(shelf()->did_add_download()); | 206 EXPECT_TRUE(shelf()->did_add_download()); |
| 207 EXPECT_TRUE(shelf()->IsShowing()); | 207 EXPECT_TRUE(shelf()->IsShowing()); |
| 208 } | 208 } |
| OLD | NEW |