blob: 162c9ce86a9bba2828dcc692509563442e7a8aa3 [file] [log] [blame]
[email protected]1db76f22012-01-16 04:00:491// 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
3// found in the LICENSE file.
4
5#include "testing/gtest/include/gtest/gtest.h"
6
7#include "base/compiler_specific.h"
8#include "chrome/browser/download/download_shelf.h"
9
10class TestDownloadShelf : public DownloadShelf {
11 public:
12 TestDownloadShelf() : is_showing_(false) {}
13
14 virtual bool IsShowing() const OVERRIDE {
15 return is_showing_;
16 }
17
18 virtual bool IsClosing() const OVERRIDE {
19 return false;
20 }
21
22 virtual Browser* browser() const OVERRIDE {
23 return NULL;
24 }
25
26 protected:
27 virtual void DoAddDownload(BaseDownloadItemModel* download_mode) OVERRIDE {}
28
29 virtual void DoShow() OVERRIDE {
30 is_showing_ = true;
31 }
32
33 virtual void DoClose() OVERRIDE {
34 is_showing_ = false;
35 }
36
37 private:
38 bool is_showing_;
39};
40
41TEST(DownloadShelfTest, ClosesShelfWhenHidden) {
42 TestDownloadShelf shelf;
43 shelf.Show();
44 EXPECT_TRUE(shelf.IsShowing());
45 shelf.Hide();
46 EXPECT_FALSE(shelf.IsShowing());
47 shelf.Unhide();
48 EXPECT_TRUE(shelf.IsShowing());
49}
50
51TEST(DownloadShelfTest, CloseWhileHiddenPreventsShowOnUnhide) {
52 TestDownloadShelf shelf;
53 shelf.Show();
54 shelf.Hide();
55 shelf.Close();
56 shelf.Unhide();
57 EXPECT_FALSE(shelf.IsShowing());
58}
59
60TEST(DownloadShelfTest, UnhideDoesntShowIfNotShownOnHide) {
61 TestDownloadShelf shelf;
62 shelf.Hide();
63 shelf.Unhide();
64 EXPECT_FALSE(shelf.IsShowing());
65}
66
67TEST(DownloadShelfTest, AddDownloadWhileHiddenUnhides) {
68 TestDownloadShelf shelf;
69 shelf.Show();
70 shelf.Hide();
71 shelf.AddDownload(NULL);
72 EXPECT_TRUE(shelf.IsShowing());
73}
74
75TEST(DownloadShelfTest, AddDownloadWhileHiddenUnhidesAndShows) {
76 TestDownloadShelf shelf;
77 shelf.Hide();
78 shelf.AddDownload(NULL);
79 EXPECT_TRUE(shelf.IsShowing());
80}