OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/offline_pages/offline_page_model.h" | 5 #include "components/offline_pages/offline_page_model.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/command_line.h" |
12 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
13 #include "base/files/scoped_temp_dir.h" | 14 #include "base/files/scoped_temp_dir.h" |
14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "base/test/test_mock_time_task_runner.h" | 18 #include "base/test/test_mock_time_task_runner.h" |
18 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
20 #include "components/bookmarks/browser/bookmark_client.h" | 21 #include "components/bookmarks/browser/bookmark_client.h" |
21 #include "components/bookmarks/browser/bookmark_model.h" | 22 #include "components/bookmarks/browser/bookmark_model.h" |
22 #include "components/bookmarks/browser/bookmark_node.h" | 23 #include "components/bookmarks/browser/bookmark_node.h" |
23 #include "components/bookmarks/browser/bookmark_storage.h" | 24 #include "components/bookmarks/browser/bookmark_storage.h" |
24 #include "components/bookmarks/browser/bookmark_undo_delegate.h" | 25 #include "components/bookmarks/browser/bookmark_undo_delegate.h" |
25 #include "components/bookmarks/browser/bookmark_undo_provider.h" | 26 #include "components/bookmarks/browser/bookmark_undo_provider.h" |
26 #include "components/bookmarks/test/test_bookmark_client.h" | 27 #include "components/bookmarks/test/test_bookmark_client.h" |
| 28 #include "components/offline_pages/offline_page_feature.h" |
27 #include "components/offline_pages/offline_page_item.h" | 29 #include "components/offline_pages/offline_page_item.h" |
| 30 #include "components/offline_pages/offline_page_switches.h" |
28 #include "components/offline_pages/offline_page_test_archiver.h" | 31 #include "components/offline_pages/offline_page_test_archiver.h" |
29 #include "components/offline_pages/offline_page_test_store.h" | 32 #include "components/offline_pages/offline_page_test_store.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
31 #include "url/gurl.h" | 34 #include "url/gurl.h" |
32 | 35 |
33 using SavePageResult = offline_pages::OfflinePageModel::SavePageResult; | 36 using SavePageResult = offline_pages::OfflinePageModel::SavePageResult; |
34 using DeletePageResult = offline_pages::OfflinePageModel::DeletePageResult; | 37 using DeletePageResult = offline_pages::OfflinePageModel::DeletePageResult; |
35 | 38 |
36 namespace offline_pages { | 39 namespace offline_pages { |
37 | 40 |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 bookmark_model()->Remove(bookmark_node); | 913 bookmark_model()->Remove(bookmark_node); |
911 PumpLoop(); | 914 PumpLoop(); |
912 EXPECT_EQ(0UL, model()->GetAllPages().size()); | 915 EXPECT_EQ(0UL, model()->GetAllPages().size()); |
913 | 916 |
914 // The offline copy should be restored upon the bookmark restore. | 917 // The offline copy should be restored upon the bookmark restore. |
915 UndoBookmarkRemoval(); | 918 UndoBookmarkRemoval(); |
916 PumpLoop(); | 919 PumpLoop(); |
917 EXPECT_EQ(1UL, model()->GetAllPages().size()); | 920 EXPECT_EQ(1UL, model()->GetAllPages().size()); |
918 } | 921 } |
919 | 922 |
| 923 TEST(CommandLineFlagsTest, OffliningRecentPages) { |
| 924 // TODO(dimich): once offline pages are enabled by default, remove this. |
| 925 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 926 switches::kEnableOfflinePages); |
| 927 |
| 928 // Disabled by default. |
| 929 EXPECT_FALSE(IsOffliningRecentPagesEnabled()); |
| 930 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 931 switches::kEnableOffliningRecentPages); |
| 932 EXPECT_TRUE(IsOffliningRecentPagesEnabled()); |
| 933 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 934 switches::kDisableOffliningRecentPages); |
| 935 EXPECT_FALSE(IsOffliningRecentPagesEnabled()); |
| 936 } |
| 937 |
920 } // namespace offline_pages | 938 } // namespace offline_pages |
OLD | NEW |