blob: 663f8b74c3194c346efc9b0db30d4a665edf0370 (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright (c) 2009 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.
#include "chrome/browser/download/download_request_infobar_delegate.h"
#include "chrome/browser/download/download_request_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
class MockTabDownloadState : public DownloadRequestManager::TabDownloadState {
public:
MockTabDownloadState() : responded_(false), accepted_(false) {
}
virtual ~MockTabDownloadState() {
EXPECT_TRUE(responded_);
}
virtual void Accept() {
EXPECT_FALSE(responded_);
responded_ = true;
accepted_ = true;
}
virtual void Cancel() {
EXPECT_FALSE(responded_);
responded_ = true;
accepted_ = false;
}
bool responded() {
return responded_;
}
bool accepted() {
return responded_ && accepted_;
}
private:
// True if we have gotten some sort of response.
bool responded_;
// True if we have gotten a Accept response. Meaningless if |responded_| is
// not true.
bool accepted_;
};
TEST(DownloadRequestInfobar, AcceptTest) {
MockTabDownloadState state;
DownloadRequestInfoBarDelegate infobar(NULL, &state);
infobar.Accept();
EXPECT_TRUE(state.accepted());
}
TEST(DownloadRequestInfobar, CancelTest) {
MockTabDownloadState state;
DownloadRequestInfoBarDelegate infobar(NULL, &state);
infobar.Cancel();
EXPECT_FALSE(state.accepted());
}
TEST(DownloadRequestInfobar, CloseTest) {
MockTabDownloadState state;
DownloadRequestInfoBarDelegate infobar(NULL, &state);
infobar.InfoBarClosed();
EXPECT_FALSE(state.accepted());
}
|