Home | History | Annotate | Download | only in shell
      1 // Copyright 2014 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef MOJO_SHELL_SHELL_TEST_HELPER_
      6 #define MOJO_SHELL_SHELL_TEST_HELPER_
      7 
      8 #include "base/macros.h"
      9 #include "base/memory/scoped_ptr.h"
     10 #include "base/run_loop.h"
     11 #include "mojo/public/interfaces/service_provider/service_provider.mojom.h"
     12 #include "mojo/service_manager/service_loader.h"
     13 #include "mojo/shell/context.h"
     14 
     15 class GURL;
     16 
     17 namespace mojo {
     18 
     19 class ServiceLoader;
     20 
     21 namespace shell {
     22 
     23 // ShellTestHelper is useful for tests to establish a connection to the
     24 // ServiceProvider. Invoke Init() to establish the connection. Once done,
     25 // service_provider() returns the handle to the ServiceProvider.
     26 class ShellTestHelper {
     27  public:
     28   ShellTestHelper();
     29   ~ShellTestHelper();
     30 
     31   void Init();
     32 
     33   // Returns a handle to the ServiceProvider. ShellTestHelper owns the
     34   // ServiceProvider.
     35   ServiceProvider* service_provider() { return service_provider_.get(); }
     36 
     37   // Sets a ServiceLoader for the specified URL. |loader| is ultimately used on
     38   // the thread this class spawns.
     39   void SetLoaderForURL(scoped_ptr<ServiceLoader> loader, const GURL& url);
     40 
     41  private:
     42   class TestServiceProvider;
     43 
     44   scoped_ptr<Context> context_;
     45 
     46   scoped_ptr<ServiceManager::TestAPI> test_api_;
     47 
     48   //  ScopedMessagePipeHandle service_provider_handle_;
     49 
     50   // Client interface for the shell.
     51   scoped_ptr<TestServiceProvider> local_service_provider_;
     52 
     53   ServiceProviderPtr service_provider_;
     54 
     55   DISALLOW_COPY_AND_ASSIGN(ShellTestHelper);
     56 };
     57 
     58 }  // namespace shell
     59 }  // namespace mojo
     60 
     61 #endif  // MOJO_SHELL_SHELL_TEST_HELPER_
     62