| 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" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "chromeos/chromeos_switches.h" | 31 #include "chromeos/chromeos_switches.h" |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 namespace utils = extension_function_test_utils; | 34 namespace utils = extension_function_test_utils; |
| 35 | 35 |
| 36 namespace extensions { | 36 namespace extensions { |
| 37 | 37 |
| 38 namespace { | 38 namespace { |
| 39 | 39 |
| 40 // If more sessions are added to session tags, num sessions should be updated. | 40 // If more sessions are added to session tags, num sessions should be updated. |
| 41 const char* kSessionTags[] = {"tag0", "tag1", "tag2", "tag3", "tag4"}; | 41 const char* const kSessionTags[] = {"tag0", "tag1", "tag2", "tag3", "tag4"}; |
| 42 const size_t kNumSessions = 5; | 42 const size_t kNumSessions = 5; |
| 43 | 43 |
| 44 void BuildSessionSpecifics(const std::string& tag, | 44 void BuildSessionSpecifics(const std::string& tag, |
| 45 sync_pb::SessionSpecifics* meta) { | 45 sync_pb::SessionSpecifics* meta) { |
| 46 meta->set_session_tag(tag); | 46 meta->set_session_tag(tag); |
| 47 sync_pb::SessionHeader* header = meta->mutable_header(); | 47 sync_pb::SessionHeader* header = meta->mutable_header(); |
| 48 header->set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_LINUX); | 48 header->set_device_type(sync_pb::SyncEnums_DeviceType_TYPE_LINUX); |
| 49 header->set_client_name(tag); | 49 header->set_client_name(tag); |
| 50 } | 50 } |
| 51 | 51 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 73 tab->set_current_navigation_index(0); | 73 tab->set_current_navigation_index(0); |
| 74 tab->set_pinned(true); | 74 tab->set_pinned(true); |
| 75 tab->set_extension_app_id("app_id"); | 75 tab->set_extension_app_id("app_id"); |
| 76 sync_pb::TabNavigation* navigation = tab->add_navigation(); | 76 sync_pb::TabNavigation* navigation = tab->add_navigation(); |
| 77 navigation->set_virtual_url("http://foo/1"); | 77 navigation->set_virtual_url("http://foo/1"); |
| 78 navigation->set_referrer("referrer"); | 78 navigation->set_referrer("referrer"); |
| 79 navigation->set_title("title"); | 79 navigation->set_title("title"); |
| 80 navigation->set_page_transition(sync_pb::SyncEnums_PageTransition_TYPED); | 80 navigation->set_page_transition(sync_pb::SyncEnums_PageTransition_TYPED); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace | 83 } // namespace |
| 84 | 84 |
| 85 class ExtensionSessionsTest : public InProcessBrowserTest { | 85 class ExtensionSessionsTest : public InProcessBrowserTest { |
| 86 public: | 86 public: |
| 87 void SetUpCommandLine(CommandLine* command_line) override; | 87 void SetUpCommandLine(CommandLine* command_line) override; |
| 88 void SetUpOnMainThread() override; | 88 void SetUpOnMainThread() override; |
| 89 | 89 |
| 90 protected: | 90 protected: |
| 91 static KeyedService* BuildProfileSyncService( | 91 static KeyedService* BuildProfileSyncService( |
| 92 content::BrowserContext* profile); | 92 content::BrowserContext* profile); |
| 93 | 93 |
| 94 void CreateTestProfileSyncService(); | 94 void CreateTestProfileSyncService(); |
| 95 void CreateTestExtension(); | 95 void CreateTestExtension(); |
| 96 void CreateSessionModels(); | 96 void CreateSessionModels(); |
| 97 | 97 |
| 98 template <class T> | 98 template <class T> |
| 99 scoped_refptr<T> CreateFunction(bool has_callback) { | 99 scoped_refptr<T> CreateFunction(bool has_callback) { |
| 100 scoped_refptr<T> fn(new T()); | 100 scoped_refptr<T> fn(new T()); |
| 101 fn->set_extension(extension_.get()); | 101 fn->set_extension(extension_.get()); |
| 102 fn->set_has_callback(has_callback); | 102 fn->set_has_callback(has_callback); |
| 103 return fn; | 103 return fn; |
| 104 }; | 104 } |
| 105 | 105 |
| 106 Browser* browser_; | 106 Browser* browser_; |
| 107 scoped_refptr<extensions::Extension> extension_; | 107 scoped_refptr<extensions::Extension> extension_; |
| 108 }; | 108 }; |
| 109 | 109 |
| 110 void ExtensionSessionsTest::SetUpCommandLine(CommandLine* command_line) { | 110 void ExtensionSessionsTest::SetUpCommandLine(CommandLine* command_line) { |
| 111 #if defined(OS_CHROMEOS) | 111 #if defined(OS_CHROMEOS) |
| 112 command_line->AppendSwitch( | 112 command_line->AppendSwitch( |
| 113 chromeos::switches::kIgnoreUserProfileMappingForTests); | 113 chromeos::switches::kIgnoreUserProfileMappingForTests); |
| 114 #endif | 114 #endif |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 361 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 362 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 362 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 363 return; | 363 return; |
| 364 #endif | 364 #endif |
| 365 | 365 |
| 366 ASSERT_TRUE(RunExtensionSubtest("sessions", | 366 ASSERT_TRUE(RunExtensionSubtest("sessions", |
| 367 "sessions.html")) << message_; | 367 "sessions.html")) << message_; |
| 368 } | 368 } |
| 369 | 369 |
| 370 } // namespace extensions | 370 } // namespace extensions |
| OLD | NEW |