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/at_exit.h" | 5 #include "base/at_exit.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/location.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/single_thread_task_runner.h" |
12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/thread_task_runner_handle.h" |
14 #include "base/value_conversions.h" | 16 #include "base/value_conversions.h" |
15 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 17 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
16 #include "chrome/browser/download/download_extensions.h" | 18 #include "chrome/browser/download/download_extensions.h" |
17 #include "chrome/browser/download/download_prefs.h" | 19 #include "chrome/browser/download/download_prefs.h" |
18 #include "chrome/browser/download/download_target_determiner.h" | 20 #include "chrome/browser/download/download_target_determiner.h" |
19 #include "chrome/browser/download/download_target_info.h" | 21 #include "chrome/browser/download/download_target_info.h" |
20 #include "chrome/browser/history/history_service_factory.h" | 22 #include "chrome/browser/history/history_service_factory.h" |
21 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 24 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
23 #include "chrome/test/base/testing_pref_service_syncable.h" | 25 #include "chrome/test/base/testing_pref_service_syncable.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // bound as that parameter. | 73 // bound as that parameter. |
72 // Example: | 74 // Example: |
73 // class FooClass { | 75 // class FooClass { |
74 // public: | 76 // public: |
75 // virtual void Foo(base::Callback<void(bool)> callback); | 77 // virtual void Foo(base::Callback<void(bool)> callback); |
76 // }; | 78 // }; |
77 // ... | 79 // ... |
78 // EXPECT_CALL(mock_fooclass_instance, Foo(callback)) | 80 // EXPECT_CALL(mock_fooclass_instance, Foo(callback)) |
79 // .WillOnce(ScheduleCallback(false)); | 81 // .WillOnce(ScheduleCallback(false)); |
80 ACTION_P(ScheduleCallback, result0) { | 82 ACTION_P(ScheduleCallback, result0) { |
81 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(arg0, result0)); | 83 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| 84 base::Bind(arg0, result0)); |
82 } | 85 } |
83 | 86 |
84 // Similar to ScheduleCallback, but binds 2 arguments. | 87 // Similar to ScheduleCallback, but binds 2 arguments. |
85 ACTION_P2(ScheduleCallback2, result0, result1) { | 88 ACTION_P2(ScheduleCallback2, result0, result1) { |
86 base::MessageLoop::current()->PostTask( | 89 base::ThreadTaskRunnerHandle::Get()->PostTask( |
87 FROM_HERE, base::Bind(arg0, result0, result1)); | 90 FROM_HERE, base::Bind(arg0, result0, result1)); |
88 } | 91 } |
89 | 92 |
90 // Used with DownloadTestCase. Indicates the type of test case. The expectations | 93 // Used with DownloadTestCase. Indicates the type of test case. The expectations |
91 // for the test is set based on the type. | 94 // for the test is set based on the type. |
92 enum TestCaseType { | 95 enum TestCaseType { |
93 SAVE_AS, | 96 SAVE_AS, |
94 AUTOMATIC, | 97 AUTOMATIC, |
95 FORCED // Requires that forced_file_path be non-empty. | 98 FORCED // Requires that forced_file_path be non-empty. |
96 }; | 99 }; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 scoped_ptr<DownloadTargetInfo> target_info = | 372 scoped_ptr<DownloadTargetInfo> target_info = |
370 RunDownloadTargetDeterminer(initial_virtual_path, item); | 373 RunDownloadTargetDeterminer(initial_virtual_path, item); |
371 VerifyDownloadTarget(test_case, target_info.get()); | 374 VerifyDownloadTarget(test_case, target_info.get()); |
372 } | 375 } |
373 | 376 |
374 void CompletionCallbackWrapper( | 377 void CompletionCallbackWrapper( |
375 const base::Closure& closure, | 378 const base::Closure& closure, |
376 scoped_ptr<DownloadTargetInfo>* target_info_receiver, | 379 scoped_ptr<DownloadTargetInfo>* target_info_receiver, |
377 scoped_ptr<DownloadTargetInfo> target_info) { | 380 scoped_ptr<DownloadTargetInfo> target_info) { |
378 target_info_receiver->swap(target_info); | 381 target_info_receiver->swap(target_info); |
379 base::MessageLoop::current()->PostTask(FROM_HERE, closure); | 382 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
380 } | 383 } |
381 | 384 |
382 scoped_ptr<DownloadTargetInfo> | 385 scoped_ptr<DownloadTargetInfo> |
383 DownloadTargetDeterminerTest::RunDownloadTargetDeterminer( | 386 DownloadTargetDeterminerTest::RunDownloadTargetDeterminer( |
384 const base::FilePath& initial_virtual_path, | 387 const base::FilePath& initial_virtual_path, |
385 content::MockDownloadItem* item) { | 388 content::MockDownloadItem* item) { |
386 scoped_ptr<DownloadTargetInfo> target_info; | 389 scoped_ptr<DownloadTargetInfo> target_info; |
387 base::RunLoop run_loop; | 390 base::RunLoop run_loop; |
388 DownloadTargetDeterminer::Start( | 391 DownloadTargetDeterminer::Start( |
389 item, initial_virtual_path, download_prefs_.get(), delegate(), | 392 item, initial_virtual_path, download_prefs_.get(), delegate(), |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2236 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) | 2239 EXPECT_CALL(mock_plugin_filter_, MockPluginAvailable(npapi_plugin.path())) |
2237 .WillRepeatedly(Return(true)); | 2240 .WillRepeatedly(Return(true)); |
2238 | 2241 |
2239 target_info = RunDownloadTargetDeterminer( | 2242 target_info = RunDownloadTargetDeterminer( |
2240 GetPathInDownloadDir(kInitialPath), item.get()); | 2243 GetPathInDownloadDir(kInitialPath), item.get()); |
2241 EXPECT_FALSE(target_info->is_filetype_handled_safely); | 2244 EXPECT_FALSE(target_info->is_filetype_handled_safely); |
2242 } | 2245 } |
2243 #endif // defined(ENABLE_PLUGINS) | 2246 #endif // defined(ENABLE_PLUGINS) |
2244 | 2247 |
2245 } // namespace | 2248 } // namespace |
OLD | NEW |