| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "extensions/browser/api/system_memory/memory_info_provider.h" | 7 #include "extensions/browser/api/system_memory/memory_info_provider.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace extensions { |
| 10 | 10 |
| 11 using core_api::system_memory::MemoryInfo; | 11 using core_api::system_memory::MemoryInfo; |
| 12 | 12 |
| 13 class MockMemoryInfoProviderImpl : public MemoryInfoProvider { | 13 class MockMemoryInfoProviderImpl : public MemoryInfoProvider { |
| 14 public: | 14 public: |
| 15 MockMemoryInfoProviderImpl() {} | 15 MockMemoryInfoProviderImpl() {} |
| 16 | 16 |
| 17 virtual bool QueryInfo() OVERRIDE { | 17 virtual bool QueryInfo() override { |
| 18 info_.capacity = 4096; | 18 info_.capacity = 4096; |
| 19 info_.available_capacity = 1024; | 19 info_.available_capacity = 1024; |
| 20 return true; | 20 return true; |
| 21 } | 21 } |
| 22 private: | 22 private: |
| 23 virtual ~MockMemoryInfoProviderImpl() {} | 23 virtual ~MockMemoryInfoProviderImpl() {} |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 class SystemMemoryApiTest: public ExtensionApiTest { | 26 class SystemMemoryApiTest: public ExtensionApiTest { |
| 27 public: | 27 public: |
| 28 SystemMemoryApiTest() {} | 28 SystemMemoryApiTest() {} |
| 29 virtual ~SystemMemoryApiTest() {} | 29 virtual ~SystemMemoryApiTest() {} |
| 30 | 30 |
| 31 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 31 virtual void SetUpInProcessBrowserTestFixture() override { |
| 32 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 32 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 33 message_loop_.reset(new base::MessageLoopForUI); | 33 message_loop_.reset(new base::MessageLoopForUI); |
| 34 } | 34 } |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 scoped_ptr<base::MessageLoop> message_loop_; | 37 scoped_ptr<base::MessageLoop> message_loop_; |
| 38 }; | 38 }; |
| 39 | 39 |
| 40 IN_PROC_BROWSER_TEST_F(SystemMemoryApiTest, Memory) { | 40 IN_PROC_BROWSER_TEST_F(SystemMemoryApiTest, Memory) { |
| 41 scoped_refptr<MemoryInfoProvider> provider = new MockMemoryInfoProviderImpl(); | 41 scoped_refptr<MemoryInfoProvider> provider = new MockMemoryInfoProviderImpl(); |
| 42 // The provider is owned by the single MemoryInfoProvider instance. | 42 // The provider is owned by the single MemoryInfoProvider instance. |
| 43 MemoryInfoProvider::InitializeForTesting(provider); | 43 MemoryInfoProvider::InitializeForTesting(provider); |
| 44 ASSERT_TRUE(RunExtensionTest("system/memory")) << message_; | 44 ASSERT_TRUE(RunExtensionTest("system/memory")) << message_; |
| 45 } | 45 } |
| 46 | 46 |
| 47 } // namespace extensions | 47 } // namespace extensions |
| OLD | NEW |