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" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 RenderViewHost* rvh = shell()->web_contents()->GetRenderViewHost(); | 67 RenderViewHost* rvh = shell()->web_contents()->GetRenderViewHost(); |
68 DevToolsAgentHost* agent = DevToolsAgentHost::GetOrCreateFor(rvh).get(); | 68 DevToolsAgentHost* agent = DevToolsAgentHost::GetOrCreateFor(rvh).get(); |
69 scoped_ptr<RendererOverridesHandler> handler( | 69 scoped_ptr<RendererOverridesHandler> handler( |
70 new RendererOverridesHandler(agent)); | 70 new RendererOverridesHandler(agent)); |
71 handler->SetNotifier(base::Bind( | 71 handler->SetNotifier(base::Bind( |
72 &RendererOverridesHandlerTest::OnMessageSent, base::Unretained(this))); | 72 &RendererOverridesHandlerTest::OnMessageSent, base::Unretained(this))); |
73 return handler.release(); | 73 return handler.release(); |
74 } | 74 } |
75 | 75 |
76 void OnMessageSent(const std::string& message) { | 76 void OnMessageSent(const std::string& message) { |
77 base::DictionaryValue* root = | 77 scoped_ptr<base::DictionaryValue> root( |
78 static_cast<base::DictionaryValue*>(base::JSONReader::Read(message)); | 78 static_cast<base::DictionaryValue*>(base::JSONReader::Read(message))); |
79 base::DictionaryValue* result; | 79 base::DictionaryValue* result; |
80 root->GetDictionary("result", &result); | 80 root->GetDictionary("result", &result); |
81 result_.reset(result); | 81 result_.reset(result->DeepCopy()); |
82 base::MessageLoop::current()->QuitNow(); | 82 base::MessageLoop::current()->QuitNow(); |
83 } | 83 } |
84 }; | 84 }; |
85 | 85 |
86 IN_PROC_BROWSER_TEST_F(RendererOverridesHandlerTest, QueryUsageAndQuota) { | 86 IN_PROC_BROWSER_TEST_F(RendererOverridesHandlerTest, QueryUsageAndQuota) { |
87 DictionaryValue* params = new DictionaryValue(); | 87 DictionaryValue* params = new DictionaryValue(); |
88 params->SetString("securityOrigin", "http://example.com"); | 88 params->SetString("securityOrigin", "http://example.com"); |
89 SendAsyncCommand("Page.queryUsageAndQuota", params); | 89 SendAsyncCommand("Page.queryUsageAndQuota", params); |
90 | 90 |
91 EXPECT_TRUE(HasValue("quota.persistent")); | 91 EXPECT_TRUE(HasValue("quota.persistent")); |
92 EXPECT_TRUE(HasValue("quota.temporary")); | 92 EXPECT_TRUE(HasValue("quota.temporary")); |
93 EXPECT_TRUE(HasListItem("usage.temporary", "id", "appcache")); | 93 EXPECT_TRUE(HasListItem("usage.temporary", "id", "appcache")); |
94 EXPECT_TRUE(HasListItem("usage.temporary", "id", "database")); | 94 EXPECT_TRUE(HasListItem("usage.temporary", "id", "database")); |
95 EXPECT_TRUE(HasListItem("usage.temporary", "id", "indexeddatabase")); | 95 EXPECT_TRUE(HasListItem("usage.temporary", "id", "indexeddatabase")); |
96 EXPECT_TRUE(HasListItem("usage.temporary", "id", "filesystem")); | 96 EXPECT_TRUE(HasListItem("usage.temporary", "id", "filesystem")); |
97 EXPECT_TRUE(HasListItem("usage.persistent", "id", "filesystem")); | 97 EXPECT_TRUE(HasListItem("usage.persistent", "id", "filesystem")); |
98 } | 98 } |
99 | 99 |
100 } // namespace content | 100 } // namespace content |
OLD | NEW |