| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
| 7 #include "chrome/browser/extensions/api/system_info_memory/memory_info_provider.
h" | 7 #include "chrome/browser/extensions/api/system_memory/memory_info_provider.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_test_message_listener.h" | 9 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/test/base/ui_test_utils.h" | 11 #include "chrome/test/base/ui_test_utils.h" |
| 12 | 12 |
| 13 namespace extensions { | 13 namespace extensions { |
| 14 | 14 |
| 15 using api::system_info_memory::MemoryInfo; | 15 using api::system_memory::MemoryInfo; |
| 16 | 16 |
| 17 const char kExtensionId[] = "lfmcnjhchhgejbpbonjobnlbcgcnmjif"; | 17 const char kExtensionId[] = "lfmcnjhchhgejbpbonjobnlbcgcnmjif"; |
| 18 | 18 |
| 19 class MockMemoryInfoProviderImpl : public MemoryInfoProvider { | 19 class MockMemoryInfoProviderImpl : public MemoryInfoProvider { |
| 20 public: | 20 public: |
| 21 MockMemoryInfoProviderImpl() {} | 21 MockMemoryInfoProviderImpl() {} |
| 22 | 22 |
| 23 virtual bool QueryInfo() OVERRIDE { | 23 virtual bool QueryInfo() OVERRIDE { |
| 24 info_.capacity = 4096; | 24 info_.capacity = 4096; |
| 25 info_.available_capacity = 1024; | 25 info_.available_capacity = 1024; |
| 26 return true; | 26 return true; |
| 27 } | 27 } |
| 28 private: | 28 private: |
| 29 virtual ~MockMemoryInfoProviderImpl() {} | 29 virtual ~MockMemoryInfoProviderImpl() {} |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 class SystemInfoMemoryApiTest: public ExtensionApiTest { | 32 class SystemMemoryApiTest: public ExtensionApiTest { |
| 33 public: | 33 public: |
| 34 SystemInfoMemoryApiTest() {} | 34 SystemMemoryApiTest() {} |
| 35 virtual ~SystemInfoMemoryApiTest() {} | 35 virtual ~SystemMemoryApiTest() {} |
| 36 | 36 |
| 37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 37 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 38 ExtensionApiTest::SetUpCommandLine(command_line); | 38 ExtensionApiTest::SetUpCommandLine(command_line); |
| 39 command_line->AppendSwitchASCII(switches::kWhitelistedExtensionID, | 39 command_line->AppendSwitchASCII(switches::kWhitelistedExtensionID, |
| 40 kExtensionId); | 40 kExtensionId); |
| 41 } | 41 } |
| 42 | 42 |
| 43 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 43 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 44 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 44 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 45 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); | 45 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 scoped_ptr<base::MessageLoop> message_loop_; | 49 scoped_ptr<base::MessageLoop> message_loop_; |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 IN_PROC_BROWSER_TEST_F(SystemInfoMemoryApiTest, Memory) { | 52 IN_PROC_BROWSER_TEST_F(SystemMemoryApiTest, Memory) { |
| 53 scoped_refptr<MemoryInfoProvider> provider = new MockMemoryInfoProviderImpl(); | 53 scoped_refptr<MemoryInfoProvider> provider = new MockMemoryInfoProviderImpl(); |
| 54 // The provider is owned by the single MemoryInfoProvider instance. | 54 // The provider is owned by the single MemoryInfoProvider instance. |
| 55 MemoryInfoProvider::InitializeForTesting(provider); | 55 MemoryInfoProvider::InitializeForTesting(provider); |
| 56 ASSERT_TRUE(RunExtensionTest("systeminfo/memory")) << message_; | 56 ASSERT_TRUE(RunExtensionTest("system/memory")) << message_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace extensions | 59 } // namespace extensions |
| OLD | NEW |