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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/json/json_reader.h" | 6 #include "base/json/json_reader.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "content/browser/devtools/renderer_overrides_handler.h" | 8 #include "content/browser/devtools/renderer_overrides_handler.h" |
9 #include "content/public/browser/devtools_agent_host.h" | 9 #include "content/public/browser/devtools_agent_host.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
11 #include "content/shell/browser/shell.h" | 11 #include "content/shell/browser/shell.h" |
12 #include "content/test/content_browser_test.h" | 12 #include "content/test/content_browser_test.h" |
13 #include "content/test/content_browser_test_utils.h" | 13 #include "content/test/content_browser_test_utils.h" |
14 | 14 |
15 namespace content { | 15 namespace content { |
16 | 16 |
17 class RendererOverridesHandlerTest : public ContentBrowserTest { | 17 class RendererOverridesHandlerTest : public ContentBrowserTest { |
18 protected: | 18 protected: |
19 scoped_refptr<DevToolsProtocol::Response> SendCommand( | 19 scoped_refptr<DevToolsProtocol::Response> SendCommand( |
20 const std::string& method, | 20 const std::string& method, |
21 DictionaryValue* params) { | 21 base::DictionaryValue* params) { |
22 scoped_ptr<RendererOverridesHandler> handler(CreateHandler()); | 22 scoped_ptr<RendererOverridesHandler> handler(CreateHandler()); |
23 scoped_refptr<DevToolsProtocol::Command> command( | 23 scoped_refptr<DevToolsProtocol::Command> command( |
24 DevToolsProtocol::CreateCommand(1, method, params)); | 24 DevToolsProtocol::CreateCommand(1, method, params)); |
25 return handler->HandleCommand(command); | 25 return handler->HandleCommand(command); |
26 } | 26 } |
27 | 27 |
28 void SendAsyncCommand(const std::string& method, DictionaryValue* params) { | 28 void SendAsyncCommand(const std::string& method, |
| 29 base::DictionaryValue* params) { |
29 scoped_ptr<RendererOverridesHandler> handler(CreateHandler()); | 30 scoped_ptr<RendererOverridesHandler> handler(CreateHandler()); |
30 scoped_refptr<DevToolsProtocol::Command> command( | 31 scoped_refptr<DevToolsProtocol::Command> command( |
31 DevToolsProtocol::CreateCommand(1, method, params)); | 32 DevToolsProtocol::CreateCommand(1, method, params)); |
32 scoped_refptr<DevToolsProtocol::Response> response = | 33 scoped_refptr<DevToolsProtocol::Response> response = |
33 handler->HandleCommand(command); | 34 handler->HandleCommand(command); |
34 EXPECT_TRUE(response->is_async_promise()); | 35 EXPECT_TRUE(response->is_async_promise()); |
35 base::MessageLoop::current()->Run(); | 36 base::MessageLoop::current()->Run(); |
36 } | 37 } |
37 | 38 |
38 bool HasValue(const std::string& path) { | 39 bool HasValue(const std::string& path) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 scoped_ptr<base::DictionaryValue> root( | 78 scoped_ptr<base::DictionaryValue> root( |
78 static_cast<base::DictionaryValue*>(base::JSONReader::Read(message))); | 79 static_cast<base::DictionaryValue*>(base::JSONReader::Read(message))); |
79 base::DictionaryValue* result; | 80 base::DictionaryValue* result; |
80 root->GetDictionary("result", &result); | 81 root->GetDictionary("result", &result); |
81 result_.reset(result->DeepCopy()); | 82 result_.reset(result->DeepCopy()); |
82 base::MessageLoop::current()->QuitNow(); | 83 base::MessageLoop::current()->QuitNow(); |
83 } | 84 } |
84 }; | 85 }; |
85 | 86 |
86 IN_PROC_BROWSER_TEST_F(RendererOverridesHandlerTest, QueryUsageAndQuota) { | 87 IN_PROC_BROWSER_TEST_F(RendererOverridesHandlerTest, QueryUsageAndQuota) { |
87 DictionaryValue* params = new DictionaryValue(); | 88 base::DictionaryValue* params = new base::DictionaryValue(); |
88 params->SetString("securityOrigin", "http://example.com"); | 89 params->SetString("securityOrigin", "http://example.com"); |
89 SendAsyncCommand("Page.queryUsageAndQuota", params); | 90 SendAsyncCommand("Page.queryUsageAndQuota", params); |
90 | 91 |
91 EXPECT_TRUE(HasValue("quota.persistent")); | 92 EXPECT_TRUE(HasValue("quota.persistent")); |
92 EXPECT_TRUE(HasValue("quota.temporary")); | 93 EXPECT_TRUE(HasValue("quota.temporary")); |
93 EXPECT_TRUE(HasListItem("usage.temporary", "id", "appcache")); | 94 EXPECT_TRUE(HasListItem("usage.temporary", "id", "appcache")); |
94 EXPECT_TRUE(HasListItem("usage.temporary", "id", "database")); | 95 EXPECT_TRUE(HasListItem("usage.temporary", "id", "database")); |
95 EXPECT_TRUE(HasListItem("usage.temporary", "id", "indexeddatabase")); | 96 EXPECT_TRUE(HasListItem("usage.temporary", "id", "indexeddatabase")); |
96 EXPECT_TRUE(HasListItem("usage.temporary", "id", "filesystem")); | 97 EXPECT_TRUE(HasListItem("usage.temporary", "id", "filesystem")); |
97 EXPECT_TRUE(HasListItem("usage.persistent", "id", "filesystem")); | 98 EXPECT_TRUE(HasListItem("usage.persistent", "id", "filesystem")); |
98 } | 99 } |
99 | 100 |
100 } // namespace content | 101 } // namespace content |
OLD | NEW |