Roll src/third_party/skia 5141d90:0e6ff38
[chromium-blink-merge.git] / chrome / test / media_router / media_router_base_browsertest.h
blobe1d29c43941c870bc411e45252880ad888fd9e86
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.
5 #ifndef CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_BASE_BROWSERTEST_H_
6 #define CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_BASE_BROWSERTEST_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/synchronization/waitable_event.h"
12 #include "base/timer/timer.h"
13 #include "chrome/browser/extensions/extension_apitest.h"
14 #include "extensions/browser/process_manager_observer.h"
16 namespace media_router {
18 class MediaRouter;
20 /**
21 * Base class for media router browser test.
23 * It provides the basic functions for integration and e2e browser tests,
24 * including install unpacked or packed extension at beginning of the test,
25 * uninstall the extension at the end of the test.
27 * This class accepts two flags to specify the location of MR extension:
28 * 1. "--extension-crx" flag to specify the packed extension location
29 * 2. "--extension-unpacked" flag to specify the unpacked extension location
30 * Only one of them should be passed when run browser tests.
32 class MediaRouterBaseBrowserTest : public ExtensionBrowserTest,
33 public extensions::ProcessManagerObserver {
34 public:
35 MediaRouterBaseBrowserTest();
36 ~MediaRouterBaseBrowserTest() override;
38 // InProcessBrowserTest Overrides
39 void SetUp() override;
40 void TearDown() override;
42 protected:
43 // InProcessBrowserTest Overrides
44 void SetUpOnMainThread() override;
45 void TearDownOnMainThread() override;
47 void InstallAndEnableMRExtension();
48 void UninstallMRExtension();
50 virtual void ParseCommandLine();
52 // extensions::ProcessManagerObserver Overrides
53 void OnBackgroundHostCreated(extensions::ExtensionHost* host) override;
55 // Wait until get the successful callback or timeout.
56 // TODO(leilei): Replace this method with WaitableEvent class.
57 void ConditionalWait(base::TimeDelta timeout,
58 base::TimeDelta interval,
59 const base::Callback<bool(void)>& callback);
61 // Wait for a specific time.
62 void Wait(base::TimeDelta timeout);
64 bool is_unpacked() const { return !extension_unpacked_.empty(); }
66 bool is_extension_host_created() const { return extension_host_created_; }
68 // These values are initialized via flags.
69 base::FilePath extension_crx_;
70 base::FilePath extension_unpacked_;
72 base::WaitableEvent extension_load_event_;
73 std::string extension_id_;
74 bool extension_host_created_;
76 private:
77 DISALLOW_COPY_AND_ASSIGN(MediaRouterBaseBrowserTest);
80 } // namespace media_router
82 #endif // CHROME_TEST_MEDIA_ROUTER_MEDIA_ROUTER_BASE_BROWSERTEST_H_