| 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 // Create a service process that uses a Mock to respond to the browser in order | 5 // Create a service process that uses a Mock to respond to the browser in order |
| 6 // to test launching the browser using the cloud print policy check command | 6 // to test launching the browser using the cloud print policy check command |
| 7 // line switch. | 7 // line switch. |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "chrome/test/base/testing_profile.h" | 43 #include "chrome/test/base/testing_profile.h" |
| 44 #include "chrome/test/base/testing_profile_manager.h" | 44 #include "chrome/test/base/testing_profile_manager.h" |
| 45 #include "components/syncable_prefs/testing_pref_service_syncable.h" | 45 #include "components/syncable_prefs/testing_pref_service_syncable.h" |
| 46 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
| 47 #include "content/public/common/content_paths.h" | 47 #include "content/public/common/content_paths.h" |
| 48 #include "content/public/test/test_browser_thread_bundle.h" | 48 #include "content/public/test/test_browser_thread_bundle.h" |
| 49 #include "content/public/test/test_utils.h" | 49 #include "content/public/test/test_utils.h" |
| 50 #include "ipc/ipc_descriptors.h" | 50 #include "ipc/ipc_descriptors.h" |
| 51 #include "ipc/ipc_multiprocess_test.h" | 51 #include "ipc/ipc_multiprocess_test.h" |
| 52 #include "ipc/ipc_switches.h" | 52 #include "ipc/ipc_switches.h" |
| 53 #include "mojo/edk/embedder/embedder.h" |
| 53 #include "testing/gmock/include/gmock/gmock.h" | 54 #include "testing/gmock/include/gmock/gmock.h" |
| 54 #include "testing/gtest/include/gtest/gtest.h" | 55 #include "testing/gtest/include/gtest/gtest.h" |
| 55 #include "testing/multiprocess_func_list.h" | 56 #include "testing/multiprocess_func_list.h" |
| 56 | 57 |
| 57 #if defined(OS_MACOSX) | 58 #if defined(OS_MACOSX) |
| 58 #include "chrome/common/mac/mock_launchd.h" | 59 #include "chrome/common/mac/mock_launchd.h" |
| 59 #endif | 60 #endif |
| 60 #if defined(OS_POSIX) | 61 #if defined(OS_POSIX) |
| 61 #include "base/posix/global_descriptors.h" | 62 #include "base/posix/global_descriptors.h" |
| 62 #endif | 63 #endif |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 if (!service_process_state_initialized) | 242 if (!service_process_state_initialized) |
| 242 return kInitializationFailure; | 243 return kInitializationFailure; |
| 243 | 244 |
| 244 TestServiceProcess service_process; | 245 TestServiceProcess service_process; |
| 245 EXPECT_EQ(&service_process, g_service_process); | 246 EXPECT_EQ(&service_process, g_service_process); |
| 246 | 247 |
| 247 // Takes ownership of the pointer, but we can use it since we have the same | 248 // Takes ownership of the pointer, but we can use it since we have the same |
| 248 // lifetime. | 249 // lifetime. |
| 249 EXPECT_TRUE(service_process.Initialize(&main_message_loop, state)); | 250 EXPECT_TRUE(service_process.Initialize(&main_message_loop, state)); |
| 250 | 251 |
| 252 // Needed for IPC. |
| 253 mojo::edk::Init(); |
| 254 |
| 251 MockServiceIPCServer server(&service_process, | 255 MockServiceIPCServer server(&service_process, |
| 252 service_process.io_task_runner(), | 256 service_process.io_task_runner(), |
| 253 state->GetServiceProcessChannel(), | 257 state->GetServiceProcessChannel(), |
| 254 service_process.GetShutdownEventForTesting()); | 258 service_process.GetShutdownEventForTesting()); |
| 255 | 259 |
| 256 // Here is where the expectations/mock responses need to be set up. | 260 // Here is where the expectations/mock responses need to be set up. |
| 257 set_expectations.Run(&server); | 261 set_expectations.Run(&server); |
| 258 | 262 |
| 259 EXPECT_TRUE(server.Init()); | 263 EXPECT_TRUE(server.Init()); |
| 260 EXPECT_TRUE(state->SignalReady(service_process.io_task_runner().get(), | 264 EXPECT_TRUE(state->SignalReady(service_process.io_task_runner().get(), |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 // LocalState for the BrowserProcess. Must be created before profiles are | 519 // LocalState for the BrowserProcess. Must be created before profiles are |
| 516 // constructed. | 520 // constructed. |
| 517 chrome::TestingIOThreadState testing_io_thread_state; | 521 chrome::TestingIOThreadState testing_io_thread_state; |
| 518 | 522 |
| 519 base::Process process = | 523 base::Process process = |
| 520 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); | 524 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); |
| 521 WaitForConnect(); | 525 WaitForConnect(); |
| 522 ShutdownAndWaitForExitWithTimeout(std::move(process)); | 526 ShutdownAndWaitForExitWithTimeout(std::move(process)); |
| 523 content::RunAllPendingInMessageLoop(); | 527 content::RunAllPendingInMessageLoop(); |
| 524 } | 528 } |
| OLD | NEW |