summaryrefslogtreecommitdiffstats
path: root/chrome/browser/download/test_download_shelf.h
blob: 9526d1e2c7e4d60124918c8b7bbf397bc2c04153 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_DOWNLOAD_TEST_DOWNLOAD_SHELF_H_
#define CHROME_BROWSER_DOWNLOAD_TEST_DOWNLOAD_SHELF_H_

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/download/download_shelf.h"
#include "content/public/browser/download_manager.h"

// An implementation of DownloadShelf for testing.
class TestDownloadShelf : public DownloadShelf,
                          public content::DownloadManager::Observer {
 public:
  TestDownloadShelf();
  virtual ~TestDownloadShelf();

  // DownloadShelf:
  virtual bool IsShowing() const OVERRIDE;
  virtual bool IsClosing() const OVERRIDE;
  virtual Browser* browser() const OVERRIDE;

  // Return |true| if a download was added to this shelf.
  bool did_add_download() const { return did_add_download_; }

  // Set download_manager_ (and the result of calling GetDownloadManager())
  void set_download_manager(content::DownloadManager* download_manager);

  // DownloadManager::Observer implementation.
  virtual void ManagerGoingDown(content::DownloadManager* manager) OVERRIDE;

 protected:
  virtual void DoAddDownload(content::DownloadItem* download) OVERRIDE;
  virtual void DoShow() OVERRIDE;
  virtual void DoClose(CloseReason reason) OVERRIDE;
  virtual base::TimeDelta GetTransientDownloadShowDelay() OVERRIDE;
  virtual content::DownloadManager* GetDownloadManager() OVERRIDE;

 private:
  bool is_showing_;
  bool did_add_download_;
  content::DownloadManager* download_manager_;

  DISALLOW_COPY_AND_ASSIGN(TestDownloadShelf);
};

#endif  // CHROME_BROWSER_DOWNLOAD_TEST_DOWNLOAD_SHELF_H_