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/base64.h" | 5 #include "base/base64.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "content/browser/devtools/devtools_protocol.h" | 8 #include "content/browser/devtools/devtools_protocol.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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 if (id == value) | 49 if (id == value) |
50 return true; | 50 return true; |
51 } | 51 } |
52 return false; | 52 return false; |
53 } | 53 } |
54 | 54 |
55 scoped_ptr<base::DictionaryValue> result_; | 55 scoped_ptr<base::DictionaryValue> result_; |
56 scoped_refptr<DevToolsAgentHost> agent_host_; | 56 scoped_refptr<DevToolsAgentHost> agent_host_; |
57 | 57 |
58 private: | 58 private: |
59 virtual void SetUpOnMainThread() OVERRIDE { | 59 virtual void SetUpOnMainThread() override { |
60 agent_host_ = DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); | 60 agent_host_ = DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); |
61 agent_host_->AttachClient(this); | 61 agent_host_->AttachClient(this); |
62 } | 62 } |
63 | 63 |
64 virtual void TearDownOnMainThread() OVERRIDE { | 64 virtual void TearDownOnMainThread() override { |
65 agent_host_->DetachClient(); | 65 agent_host_->DetachClient(); |
66 agent_host_ = NULL; | 66 agent_host_ = NULL; |
67 } | 67 } |
68 | 68 |
69 virtual void DispatchProtocolMessage( | 69 virtual void DispatchProtocolMessage( |
70 DevToolsAgentHost* agent_host, const std::string& message) OVERRIDE { | 70 DevToolsAgentHost* agent_host, const std::string& message) override { |
71 scoped_ptr<base::DictionaryValue> root( | 71 scoped_ptr<base::DictionaryValue> root( |
72 static_cast<base::DictionaryValue*>(base::JSONReader::Read(message))); | 72 static_cast<base::DictionaryValue*>(base::JSONReader::Read(message))); |
73 base::DictionaryValue* result; | 73 base::DictionaryValue* result; |
74 EXPECT_TRUE(root->GetDictionary("result", &result)); | 74 EXPECT_TRUE(root->GetDictionary("result", &result)); |
75 result_.reset(result->DeepCopy()); | 75 result_.reset(result->DeepCopy()); |
76 base::MessageLoop::current()->QuitNow(); | 76 base::MessageLoop::current()->QuitNow(); |
77 } | 77 } |
78 | 78 |
79 virtual void AgentHostClosed( | 79 virtual void AgentHostClosed( |
80 DevToolsAgentHost* agent_host, bool replaced) OVERRIDE { | 80 DevToolsAgentHost* agent_host, bool replaced) override { |
81 EXPECT_TRUE(false); | 81 EXPECT_TRUE(false); |
82 } | 82 } |
83 }; | 83 }; |
84 | 84 |
85 IN_PROC_BROWSER_TEST_F(RendererOverridesHandlerTest, QueryUsageAndQuota) { | 85 IN_PROC_BROWSER_TEST_F(RendererOverridesHandlerTest, QueryUsageAndQuota) { |
86 base::DictionaryValue* params = new base::DictionaryValue(); | 86 base::DictionaryValue* params = new base::DictionaryValue(); |
87 params->SetString("securityOrigin", "http://example.com"); | 87 params->SetString("securityOrigin", "http://example.com"); |
88 SendCommand("Page.queryUsageAndQuota", params); | 88 SendCommand("Page.queryUsageAndQuota", params); |
89 | 89 |
90 EXPECT_TRUE(HasValue("quota.persistent")); | 90 EXPECT_TRUE(HasValue("quota.persistent")); |
91 EXPECT_TRUE(HasValue("quota.temporary")); | 91 EXPECT_TRUE(HasValue("quota.temporary")); |
92 EXPECT_TRUE(HasListItem("usage.temporary", "id", "appcache")); | 92 EXPECT_TRUE(HasListItem("usage.temporary", "id", "appcache")); |
93 EXPECT_TRUE(HasListItem("usage.temporary", "id", "database")); | 93 EXPECT_TRUE(HasListItem("usage.temporary", "id", "database")); |
94 EXPECT_TRUE(HasListItem("usage.temporary", "id", "indexeddatabase")); | 94 EXPECT_TRUE(HasListItem("usage.temporary", "id", "indexeddatabase")); |
95 EXPECT_TRUE(HasListItem("usage.temporary", "id", "filesystem")); | 95 EXPECT_TRUE(HasListItem("usage.temporary", "id", "filesystem")); |
96 EXPECT_TRUE(HasListItem("usage.persistent", "id", "filesystem")); | 96 EXPECT_TRUE(HasListItem("usage.persistent", "id", "filesystem")); |
97 } | 97 } |
98 | 98 |
99 class CaptureScreenshotTest : public RendererOverridesHandlerTest { | 99 class CaptureScreenshotTest : public RendererOverridesHandlerTest { |
100 private: | 100 private: |
101 #if !defined(OS_ANDROID) | 101 #if !defined(OS_ANDROID) |
102 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE { | 102 virtual void SetUpCommandLine(base::CommandLine* command_line) override { |
103 command_line->AppendSwitch(switches::kEnablePixelOutputInTests); | 103 command_line->AppendSwitch(switches::kEnablePixelOutputInTests); |
104 } | 104 } |
105 #endif | 105 #endif |
106 }; | 106 }; |
107 | 107 |
108 // Does not link on Android | 108 // Does not link on Android |
109 #if defined(OS_ANDROID) | 109 #if defined(OS_ANDROID) |
110 #define MAYBE_CaptureScreenshot DISABLED_CaptureScreenshot | 110 #define MAYBE_CaptureScreenshot DISABLED_CaptureScreenshot |
111 #else | 111 #else |
112 #define MAYBE_CaptureScreenshot CaptureScreenshot | 112 #define MAYBE_CaptureScreenshot CaptureScreenshot |
(...skipping 11 matching lines...) Expand all Loading... |
124 SkBitmap bitmap; | 124 SkBitmap bitmap; |
125 gfx::PNGCodec::Decode(reinterpret_cast<const unsigned char*>(png.data()), | 125 gfx::PNGCodec::Decode(reinterpret_cast<const unsigned char*>(png.data()), |
126 png.size(), &bitmap); | 126 png.size(), &bitmap); |
127 SkColor color(bitmap.getColor(0, 0)); | 127 SkColor color(bitmap.getColor(0, 0)); |
128 EXPECT_TRUE(std::abs(0x12-(int)SkColorGetR(color)) <= 1); | 128 EXPECT_TRUE(std::abs(0x12-(int)SkColorGetR(color)) <= 1); |
129 EXPECT_TRUE(std::abs(0x34-(int)SkColorGetG(color)) <= 1); | 129 EXPECT_TRUE(std::abs(0x34-(int)SkColorGetG(color)) <= 1); |
130 EXPECT_TRUE(std::abs(0x56-(int)SkColorGetB(color)) <= 1); | 130 EXPECT_TRUE(std::abs(0x56-(int)SkColorGetB(color)) <= 1); |
131 } | 131 } |
132 | 132 |
133 } // namespace content | 133 } // namespace content |
OLD | NEW |