OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/download/download_id.h" | 5 #include "content/browser/download/download_id.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "content/browser/download/mock_download_manager.h" |
12 #include "content/browser/download/mock_download_manager_delegate.h" | 13 #include "content/browser/download/mock_download_manager_delegate.h" |
13 #include "content/browser/download/mock_download_manager.h" | 14 #include "content/test/test_browser_thread.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 class DownloadIdTest : public testing::Test { | 17 class DownloadIdTest : public testing::Test { |
17 public: | 18 public: |
18 DownloadIdTest() | 19 DownloadIdTest() |
19 : download_manager_delegate_(new MockDownloadManagerDelegate), | 20 : download_manager_delegate_(new MockDownloadManagerDelegate), |
20 ui_thread_(BrowserThread::UI, &message_loop_) { | 21 ui_thread_(BrowserThread::UI, &message_loop_) { |
21 num_managers_ = ARRAYSIZE_UNSAFE(download_managers_); | 22 num_managers_ = ARRAYSIZE_UNSAFE(download_managers_); |
22 std::vector<MockDownloadManager*> managers; | 23 std::vector<MockDownloadManager*> managers; |
23 managers.resize(num_managers_); | 24 managers.resize(num_managers_); |
(...skipping 14 matching lines...) Expand all Loading... |
38 | 39 |
39 ~DownloadIdTest() { | 40 ~DownloadIdTest() { |
40 for (size_t i = 0; i < num_managers_; ++i) | 41 for (size_t i = 0; i < num_managers_; ++i) |
41 download_managers_[i] = NULL; // Releases & deletes. | 42 download_managers_[i] = NULL; // Releases & deletes. |
42 } | 43 } |
43 | 44 |
44 protected: | 45 protected: |
45 scoped_ptr<MockDownloadManagerDelegate> download_manager_delegate_; | 46 scoped_ptr<MockDownloadManagerDelegate> download_manager_delegate_; |
46 scoped_refptr<DownloadManager> download_managers_[2]; | 47 scoped_refptr<DownloadManager> download_managers_[2]; |
47 MessageLoopForUI message_loop_; | 48 MessageLoopForUI message_loop_; |
48 BrowserThread ui_thread_; // Necessary to delete |DownloadManager|s. | 49 // Necessary to delete |DownloadManager|s. |
| 50 content::TestBrowserThread ui_thread_; |
49 size_t num_managers_; | 51 size_t num_managers_; |
50 | 52 |
51 DISALLOW_COPY_AND_ASSIGN(DownloadIdTest); | 53 DISALLOW_COPY_AND_ASSIGN(DownloadIdTest); |
52 }; | 54 }; |
53 | 55 |
54 TEST_F(DownloadIdTest, Local) { | 56 TEST_F(DownloadIdTest, Local) { |
55 DownloadId id1(download_managers_[0], 23); | 57 DownloadId id1(download_managers_[0], 23); |
56 DownloadId id2(download_managers_[0], 25); | 58 DownloadId id2(download_managers_[0], 25); |
57 | 59 |
58 EXPECT_EQ(23, id1.local()); | 60 EXPECT_EQ(23, id1.local()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 EXPECT_EQ(kLocalId[2], map[id3]); | 142 EXPECT_EQ(kLocalId[2], map[id3]); |
141 last = map.end(); | 143 last = map.end(); |
142 EXPECT_FALSE(last == map.find(id1)); | 144 EXPECT_FALSE(last == map.find(id1)); |
143 EXPECT_FALSE(last == map.find(id2)); | 145 EXPECT_FALSE(last == map.find(id2)); |
144 EXPECT_FALSE(last == map.find(id3)); | 146 EXPECT_FALSE(last == map.find(id3)); |
145 | 147 |
146 EXPECT_FALSE(id1 == id2); | 148 EXPECT_FALSE(id1 == id2); |
147 EXPECT_LT(id1, id2); | 149 EXPECT_LT(id1, id2); |
148 } | 150 } |
149 | 151 |
OLD | NEW |