OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/extensions/api/sessions/sessions_api.h" | 5 #include "chrome/browser/extensions/api/sessions/sessions_api.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
11 #include "chrome/browser/extensions/extension_apitest.h" | 11 #include "chrome/browser/extensions/extension_apitest.h" |
12 #include "chrome/browser/extensions/extension_function_test_utils.h" | 12 #include "chrome/browser/extensions/extension_function_test_utils.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/sync/glue/session_model_associator.h" | 14 #include "chrome/browser/sync/glue/session_model_associator.h" |
15 #include "chrome/browser/sync/open_tabs_ui_delegate.h" | 15 #include "chrome/browser/sync/open_tabs_ui_delegate.h" |
16 #include "chrome/browser/sync/profile_sync_service.h" | 16 #include "chrome/browser/sync/profile_sync_service.h" |
17 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
18 #include "chrome/browser/sync/profile_sync_service_mock.h" | 18 #include "chrome/browser/sync/profile_sync_service_mock.h" |
19 #include "chrome/common/chrome_paths.h" | 19 #include "chrome/common/chrome_paths.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chrome/test/base/test_switches.h" | 22 #include "chrome/test/base/test_switches.h" |
23 #include "chrome/test/base/testing_browser_process.h" | 23 #include "chrome/test/base/testing_browser_process.h" |
| 24 #include "sync/api/attachments/attachment_id.h" |
| 25 #include "sync/api/attachments/attachment_service_proxy_for_test.h" |
24 #include "sync/api/fake_sync_change_processor.h" | 26 #include "sync/api/fake_sync_change_processor.h" |
25 #include "sync/api/sync_error_factory_mock.h" | 27 #include "sync/api/sync_error_factory_mock.h" |
26 | 28 |
27 namespace utils = extension_function_test_utils; | 29 namespace utils = extension_function_test_utils; |
28 | 30 |
29 namespace extensions { | 31 namespace extensions { |
30 | 32 |
31 namespace { | 33 namespace { |
32 | 34 |
33 // If more sessions are added to session tags, num sessions should be updated. | 35 // If more sessions are added to session tags, num sessions should be updated. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 std::vector<sync_pb::SessionSpecifics> tabs1; | 177 std::vector<sync_pb::SessionSpecifics> tabs1; |
176 tabs1.resize(tab_list1.size()); | 178 tabs1.resize(tab_list1.size()); |
177 for (size_t i = 0; i < tab_list1.size(); ++i) { | 179 for (size_t i = 0; i < tab_list1.size(); ++i) { |
178 BuildTabSpecifics(kSessionTags[index], 0, tab_list1[i], &tabs1[i]); | 180 BuildTabSpecifics(kSessionTags[index], 0, tab_list1[i], &tabs1[i]); |
179 } | 181 } |
180 | 182 |
181 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 183 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
182 switches::kDisableSyncSessionsV2)) { | 184 switches::kDisableSyncSessionsV2)) { |
183 sync_pb::EntitySpecifics entity; | 185 sync_pb::EntitySpecifics entity; |
184 entity.mutable_session()->CopyFrom(meta); | 186 entity.mutable_session()->CopyFrom(meta); |
185 initial_data.push_back( | 187 initial_data.push_back(syncer::SyncData::CreateRemoteData( |
186 syncer::SyncData::CreateRemoteData(1, entity, base::Time())); | 188 1, |
| 189 entity, |
| 190 base::Time(), |
| 191 syncer::AttachmentIdList(), |
| 192 syncer::AttachmentServiceProxyForTest::Create())); |
187 for (size_t i = 0; i < tabs1.size(); i++) { | 193 for (size_t i = 0; i < tabs1.size(); i++) { |
188 sync_pb::EntitySpecifics entity; | 194 sync_pb::EntitySpecifics entity; |
189 entity.mutable_session()->CopyFrom(tabs1[i]); | 195 entity.mutable_session()->CopyFrom(tabs1[i]); |
190 initial_data.push_back(syncer::SyncData::CreateRemoteData( | 196 initial_data.push_back(syncer::SyncData::CreateRemoteData( |
191 i + 2, entity, base::Time())); | 197 i + 2, |
| 198 entity, |
| 199 base::Time(), |
| 200 syncer::AttachmentIdList(), |
| 201 syncer::AttachmentServiceProxyForTest::Create())); |
192 } | 202 } |
193 } else { | 203 } else { |
194 // Update associator with the session's meta node containing one window. | 204 // Update associator with the session's meta node containing one window. |
195 associator_->AssociateForeignSpecifics(meta, base::Time()); | 205 associator_->AssociateForeignSpecifics(meta, base::Time()); |
196 // Add tabs for the window. | 206 // Add tabs for the window. |
197 std::vector<sync_pb::SessionSpecifics>::iterator iter; | 207 std::vector<sync_pb::SessionSpecifics>::iterator iter; |
198 for (iter = tabs1.begin(); iter != tabs1.end(); ++iter) { | 208 for (iter = tabs1.begin(); iter != tabs1.end(); ++iter) { |
199 associator_->AssociateForeignSpecifics(*iter, base::Time()); | 209 associator_->AssociateForeignSpecifics(*iter, base::Time()); |
200 } | 210 } |
201 } | 211 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 353 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
344 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 354 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
345 return; | 355 return; |
346 #endif | 356 #endif |
347 | 357 |
348 ASSERT_TRUE(RunExtensionSubtest("sessions", | 358 ASSERT_TRUE(RunExtensionSubtest("sessions", |
349 "sessions.html")) << message_; | 359 "sessions.html")) << message_; |
350 } | 360 } |
351 | 361 |
352 } // namespace extensions | 362 } // namespace extensions |
OLD | NEW |