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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "ui/base/ui_base_types.h" | 52 #include "ui/base/ui_base_types.h" |
53 | 53 |
54 using browser_sync::SessionChangeProcessor; | 54 using browser_sync::SessionChangeProcessor; |
55 using browser_sync::SessionDataTypeController; | 55 using browser_sync::SessionDataTypeController; |
56 using browser_sync::SessionModelAssociator; | 56 using browser_sync::SessionModelAssociator; |
57 using browser_sync::SyncBackendHost; | 57 using browser_sync::SyncBackendHost; |
58 using content::BrowserThread; | 58 using content::BrowserThread; |
59 using syncer::ChangeRecord; | 59 using syncer::ChangeRecord; |
60 using testing::_; | 60 using testing::_; |
61 using testing::Return; | 61 using testing::Return; |
62 using syncer::TestIdFactory; | |
63 | 62 |
64 namespace browser_sync { | 63 namespace browser_sync { |
65 | 64 |
66 namespace { | 65 namespace { |
67 | 66 |
68 void BuildSessionSpecifics(const std::string& tag, | 67 void BuildSessionSpecifics(const std::string& tag, |
69 sync_pb::SessionSpecifics* meta) { | 68 sync_pb::SessionSpecifics* meta) { |
70 meta->set_session_tag(tag); | 69 meta->set_session_tag(tag); |
71 sync_pb::SessionHeader* header = meta->mutable_header(); | 70 sync_pb::SessionHeader* header = meta->mutable_header(); |
72 header->set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_LINUX); | 71 header->set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_LINUX); |
73 header->set_client_name("name"); | 72 header->set_client_name("name"); |
74 } | 73 } |
75 | 74 |
76 void AddWindowSpecifics(int window_id, | 75 void AddWindowSpecifics(int window_id, |
77 const std::vector<int>& tab_list, | 76 const std::vector<int>& tab_list, |
78 sync_pb::SessionSpecifics* meta) { | 77 sync_pb::SessionSpecifics* meta) { |
79 sync_pb::SessionHeader* header = meta->mutable_header(); | 78 sync_pb::SessionHeader* header = meta->mutable_header(); |
80 sync_pb::SessionWindow* window = header->add_window(); | 79 sync_pb::SessionWindow* window = header->add_window(); |
81 window->set_window_id(window_id); | 80 window->set_window_id(window_id); |
82 window->set_selected_tab_index(0); | 81 window->set_selected_tab_index(0); |
83 window->set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED); | 82 window->set_browser_type(sync_pb::SessionWindow_BrowserType_TYPE_TABBED); |
84 for (std::vector<int>::const_iterator iter = tab_list.begin(); | 83 for (std::vector<int>::const_iterator iter = tab_list.begin(); |
85 iter != tab_list.end(); ++iter) { | 84 iter != tab_list.end(); ++iter) { |
86 window->add_tab(*iter); | 85 window->add_tab(*iter); |
87 } | 86 } |
88 } | 87 } |
89 | 88 |
90 void BuildTabSpecifics(const std::string& tag, int window_id, int tab_id, | 89 void BuildTabSpecifics(const std::string& tag, int window_id, int tab_id, |
91 sync_pb::SessionSpecifics* tab_base) { | 90 sync_pb::SessionSpecifics* tab_base) { |
92 tab_base->set_session_tag(tag); | 91 tab_base->set_session_tag(tag); |
93 sync_pb::SessionTab* tab = tab_base->mutable_tab(); | 92 sync_pb::SessionTab* tab = tab_base->mutable_tab(); |
94 tab->set_tab_id(tab_id); | 93 tab->set_tab_id(tab_id); |
95 tab->set_tab_visual_index(1); | 94 tab->set_tab_visual_index(1); |
96 tab->set_current_navigation_index(0); | 95 tab->set_current_navigation_index(0); |
97 tab->set_pinned(true); | 96 tab->set_pinned(true); |
98 tab->set_extension_app_id("app_id"); | 97 tab->set_extension_app_id("app_id"); |
99 sync_pb::TabNavigation* navigation = tab->add_navigation(); | 98 sync_pb::TabNavigation* navigation = tab->add_navigation(); |
100 navigation->set_virtual_url("http://foo/1"); | 99 navigation->set_virtual_url("http://foo/1"); |
101 navigation->set_referrer("referrer"); | 100 navigation->set_referrer("referrer"); |
(...skipping 1094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 sync_pb::SessionSpecifics specifics; | 1195 sync_pb::SessionSpecifics specifics; |
1197 header.SetSessionSpecifics(specifics); | 1196 header.SetSessionSpecifics(specifics); |
1198 } | 1197 } |
1199 // Ensure we associate properly despite the pre-existing node with our local | 1198 // Ensure we associate properly despite the pre-existing node with our local |
1200 // tag. | 1199 // tag. |
1201 error = model_associator_->AssociateModels(NULL, NULL); | 1200 error = model_associator_->AssociateModels(NULL, NULL); |
1202 ASSERT_FALSE(error.IsSet()); | 1201 ASSERT_FALSE(error.IsSet()); |
1203 } | 1202 } |
1204 | 1203 |
1205 } // namespace browser_sync | 1204 } // namespace browser_sync |
OLD | NEW |