Adding instrumentation to locate the source of jankiness
[chromium-blink-merge.git] / chrome / browser / component_updater / test / component_updater_service_unittest.h
blobfec1d10e215391e7825ebbbdef593737f032936e
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST_H_
6 #define CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/files/file_path.h"
12 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "components/component_updater/component_updater_service.h"
15 #include "content/public/test/test_browser_thread_bundle.h"
16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h"
19 namespace net {
20 class LocalHostTestURLRequestInterceptor;
23 namespace component_updater {
25 class InterceptorFactory;
26 class TestConfigurator;
27 class TestInstaller;
28 class URLRequestPostInterceptor;
30 // Intercepts HTTP GET requests sent to "localhost".
31 typedef net::LocalHostTestURLRequestInterceptor GetInterceptor;
33 class ComponentUpdaterTest : public testing::Test {
34 public:
35 enum TestComponents {
36 kTestComponent_abag,
37 kTestComponent_jebg,
38 kTestComponent_ihfo,
41 ComponentUpdaterTest();
43 virtual ~ComponentUpdaterTest();
45 virtual void SetUp();
47 virtual void TearDown();
49 ComponentUpdateService* component_updater();
51 // Makes the full path to a component updater test file.
52 const base::FilePath test_file(const char* file);
54 TestConfigurator* test_configurator();
56 ComponentUpdateService::Status RegisterComponent(CrxComponent* com,
57 TestComponents component,
58 const Version& version,
59 TestInstaller* installer);
61 protected:
62 void RunThreads();
63 void RunThreadsUntilIdle();
65 scoped_ptr<InterceptorFactory> interceptor_factory_;
66 URLRequestPostInterceptor* post_interceptor_; // Owned by the factory.
68 scoped_ptr<GetInterceptor> get_interceptor_;
70 private:
71 TestConfigurator* test_config_;
72 content::TestBrowserThreadBundle thread_bundle_;
73 scoped_ptr<ComponentUpdateService> component_updater_;
76 const char expected_crx_url[] =
77 "http://localhost/download/jebgalgnebhfojomionfpkfelancnnkf.crx";
79 class MockServiceObserver : public ServiceObserver {
80 public:
81 MockServiceObserver();
82 ~MockServiceObserver();
83 MOCK_METHOD2(OnEvent, void(Events event, const std::string&));
86 class OnDemandTester {
87 public:
88 static ComponentUpdateService::Status OnDemand(
89 ComponentUpdateService* cus,
90 const std::string& component_id);
93 } // namespace component_updater
95 #endif // CHROME_BROWSER_COMPONENT_UPDATER_TEST_COMPONENT_UPDATER_SERVICE_UNITTEST_H_