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 "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 using testing::ReturnRefOfCopy; | 26 using testing::ReturnRefOfCopy; |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // MockDownloadItem with real observers and state. | 30 // MockDownloadItem with real observers and state. |
31 class FakeDownloadItem : public MockDownloadItem { | 31 class FakeDownloadItem : public MockDownloadItem { |
32 public: | 32 public: |
33 explicit FakeDownloadItem() | 33 explicit FakeDownloadItem() |
34 : state_(IN_PROGRESS) { | 34 : state_(IN_PROGRESS) { |
35 } | 35 } |
36 ~FakeDownloadItem() { | 36 virtual ~FakeDownloadItem() { |
37 SetState(REMOVING); | |
asanka
2012/07/11 18:12:19
You are going to need a FOR_EACH_OBSERVER(.. OnDow
benjhayden
2012/07/13 20:03:17
Done.
| |
38 EXPECT_EQ(0u, observers_.size()); | 37 EXPECT_EQ(0u, observers_.size()); |
39 } | 38 } |
40 virtual void AddObserver(Observer* observer) OVERRIDE { | 39 virtual void AddObserver(Observer* observer) OVERRIDE { |
41 observers_.AddObserver(observer); | 40 observers_.AddObserver(observer); |
42 } | 41 } |
43 virtual void RemoveObserver(Observer* observer) OVERRIDE { | 42 virtual void RemoveObserver(Observer* observer) OVERRIDE { |
44 observers_.RemoveObserver(observer); | 43 observers_.RemoveObserver(observer); |
45 } | 44 } |
46 virtual void UpdateObservers() OVERRIDE { | 45 virtual void UpdateObservers() OVERRIDE { |
47 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); | 46 FOR_EACH_OBSERVER(Observer, observers_, OnDownloadUpdated(this)); |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 item->UpdateObservers(); | 416 item->UpdateObservers(); |
418 message_loop_.RunAllPending(); | 417 message_loop_.RunAllPending(); |
419 EXPECT_FALSE(IsPathInUse(path)); | 418 EXPECT_FALSE(IsPathInUse(path)); |
420 EXPECT_TRUE(IsPathInUse(new_target_path)); | 419 EXPECT_TRUE(IsPathInUse(new_target_path)); |
421 | 420 |
422 // Destroying the item should release the reservation. | 421 // Destroying the item should release the reservation. |
423 item.reset(); | 422 item.reset(); |
424 message_loop_.RunAllPending(); | 423 message_loop_.RunAllPending(); |
425 EXPECT_FALSE(IsPathInUse(new_target_path)); | 424 EXPECT_FALSE(IsPathInUse(new_target_path)); |
426 } | 425 } |
OLD | NEW |