OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_BASE_BROWSERTEST_H_ |
| 6 #define CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_BASE_BROWSERTEST_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/timer/timer.h" |
| 12 #include "chrome/browser/extensions/extension_apitest.h" |
| 13 #include "extensions/browser/process_manager_observer.h" |
| 14 |
| 15 namespace media_router { |
| 16 |
| 17 class MediaRouter; |
| 18 |
| 19 /** |
| 20 * Base class for media router browser test. |
| 21 * |
| 22 * It provides the basic functions for integration and e2e browser tests, |
| 23 * including install unpacked or packed extension at beginning of the test, |
| 24 * uninstall the extension at the end of the test. |
| 25 * |
| 26 * This class accepts two flags to specify the location of MR extension: |
| 27 * 1. "--extension-crx" flag to specify the packed extension location |
| 28 * 2. "--extension-unpacked" flag to specify the unpacked extension location |
| 29 * Only one of them should be passed when run browser tests. |
| 30 */ |
| 31 class MediaRouterBaseBrowserTest : public ExtensionBrowserTest, |
| 32 public extensions::ProcessManagerObserver { |
| 33 public: |
| 34 MediaRouterBaseBrowserTest(); |
| 35 ~MediaRouterBaseBrowserTest() override; |
| 36 |
| 37 // InProcessBrowserTest Overrides |
| 38 void SetUp() override; |
| 39 void TearDown() override; |
| 40 |
| 41 protected: |
| 42 // InProcessBrowserTest Overrides |
| 43 void SetUpOnMainThread() override; |
| 44 void TearDownOnMainThread() override; |
| 45 |
| 46 void InstallAndEnableMRExtension(); |
| 47 void UninstallMRExtension(); |
| 48 |
| 49 virtual void ParseCommandLine(); |
| 50 |
| 51 // extensions::ProcessManagerObserver Overrides |
| 52 void OnBackgroundHostCreated(extensions::ExtensionHost* host) override; |
| 53 |
| 54 // Wait until get the successful callback or timeout. |
| 55 void Wait(base::TimeDelta timeout, |
| 56 base::TimeDelta interval, |
| 57 const base::Callback<bool(void)>& callback); |
| 58 |
| 59 // Wait for a specific time. |
| 60 void Wait(base::TimeDelta timeout); |
| 61 |
| 62 bool is_unpacked() const { return !extension_unpacked_.empty(); } |
| 63 |
| 64 bool is_extension_host_created() const { return extension_host_created_; } |
| 65 |
| 66 // These values are initialized via flags. |
| 67 base::FilePath extension_crx_; |
| 68 base::FilePath extension_unpacked_; |
| 69 |
| 70 std::string extension_id_; |
| 71 bool extension_host_created_; |
| 72 }; |
| 73 |
| 74 } // namespace media_router |
| 75 |
| 76 #endif // CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_BASE_BROWSERTEST_H_ |
OLD | NEW |