| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 const gfx::Size& GetPreferredSize() { | 366 const gfx::Size& GetPreferredSize() { |
| 367 view()->CheckPreferredSize(); | 367 view()->CheckPreferredSize(); |
| 368 return view()->preferred_size_; | 368 return view()->preferred_size_; |
| 369 } | 369 } |
| 370 | 370 |
| 371 void SetZoomLevel(double level) { | 371 void SetZoomLevel(double level) { |
| 372 view()->OnSetZoomLevelForView(false, level); | 372 view()->OnSetZoomLevelForView(false, level); |
| 373 } | 373 } |
| 374 | 374 |
| 375 private: | 375 private: |
| 376 scoped_ptr<MockKeyboard> mock_keyboard_; | 376 std::unique_ptr<MockKeyboard> mock_keyboard_; |
| 377 }; | 377 }; |
| 378 | 378 |
| 379 class DevToolsAgentTest : public RenderViewImplTest { | 379 class DevToolsAgentTest : public RenderViewImplTest { |
| 380 public: | 380 public: |
| 381 void Attach() { | 381 void Attach() { |
| 382 notifications_ = std::vector<std::string>(); | 382 notifications_ = std::vector<std::string>(); |
| 383 std::string host_id = "host_id"; | 383 std::string host_id = "host_id"; |
| 384 agent()->OnAttach(host_id, 17); | 384 agent()->OnAttach(host_id, 17); |
| 385 agent()->send_protocol_message_callback_for_test_ = base::Bind( | 385 agent()->send_protocol_message_callback_for_test_ = base::Bind( |
| 386 &DevToolsAgentTest::OnDevToolsMessage, base::Unretained(this)); | 386 &DevToolsAgentTest::OnDevToolsMessage, base::Unretained(this)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 399 agent()->OnDispatchOnInspectorBackend(17, message); | 399 agent()->OnDispatchOnInspectorBackend(17, message); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void CloseWhilePaused() { | 402 void CloseWhilePaused() { |
| 403 EXPECT_TRUE(IsPaused()); | 403 EXPECT_TRUE(IsPaused()); |
| 404 view()->NotifyOnClose(); | 404 view()->NotifyOnClose(); |
| 405 } | 405 } |
| 406 | 406 |
| 407 void OnDevToolsMessage( | 407 void OnDevToolsMessage( |
| 408 int, int, const std::string& message, const std::string&) { | 408 int, int, const std::string& message, const std::string&) { |
| 409 scoped_ptr<base::DictionaryValue> root(static_cast<base::DictionaryValue*>( | 409 std::unique_ptr<base::DictionaryValue> root( |
| 410 base::JSONReader::Read(message).release())); | 410 static_cast<base::DictionaryValue*>( |
| 411 base::JSONReader::Read(message).release())); |
| 411 int id; | 412 int id; |
| 412 if (!root->GetInteger("id", &id)) { | 413 if (!root->GetInteger("id", &id)) { |
| 413 std::string notification; | 414 std::string notification; |
| 414 EXPECT_TRUE(root->GetString("method", ¬ification)); | 415 EXPECT_TRUE(root->GetString("method", ¬ification)); |
| 415 notifications_.push_back(notification); | 416 notifications_.push_back(notification); |
| 416 } | 417 } |
| 417 } | 418 } |
| 418 | 419 |
| 419 int CountNotifications(const std::string& notification) { | 420 int CountNotifications(const std::string& notification) { |
| 420 int result = 0; | 421 int result = 0; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 FrameHostMsg_DidCommitProvisionalLoad::ID); | 615 FrameHostMsg_DidCommitProvisionalLoad::ID); |
| 615 EXPECT_TRUE(frame_navigate_msg); | 616 EXPECT_TRUE(frame_navigate_msg); |
| 616 | 617 |
| 617 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; | 618 FrameHostMsg_DidCommitProvisionalLoad::Param host_nav_params; |
| 618 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, | 619 FrameHostMsg_DidCommitProvisionalLoad::Read(frame_navigate_msg, |
| 619 &host_nav_params); | 620 &host_nav_params); |
| 620 EXPECT_TRUE(base::get<0>(host_nav_params).is_post); | 621 EXPECT_TRUE(base::get<0>(host_nav_params).is_post); |
| 621 | 622 |
| 622 // Check post data sent to browser matches | 623 // Check post data sent to browser matches |
| 623 EXPECT_TRUE(base::get<0>(host_nav_params).page_state.IsValid()); | 624 EXPECT_TRUE(base::get<0>(host_nav_params).page_state.IsValid()); |
| 624 scoped_ptr<HistoryEntry> entry = | 625 std::unique_ptr<HistoryEntry> entry = |
| 625 PageStateToHistoryEntry(base::get<0>(host_nav_params).page_state); | 626 PageStateToHistoryEntry(base::get<0>(host_nav_params).page_state); |
| 626 blink::WebHTTPBody body = entry->root().httpBody(); | 627 blink::WebHTTPBody body = entry->root().httpBody(); |
| 627 blink::WebHTTPBody::Element element; | 628 blink::WebHTTPBody::Element element; |
| 628 bool successful = body.elementAt(0, element); | 629 bool successful = body.elementAt(0, element); |
| 629 EXPECT_TRUE(successful); | 630 EXPECT_TRUE(successful); |
| 630 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); | 631 EXPECT_EQ(blink::WebHTTPBody::Element::TypeData, element.type); |
| 631 EXPECT_EQ(length, element.data.size()); | 632 EXPECT_EQ(length, element.data.size()); |
| 632 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); | 633 EXPECT_EQ(0, memcmp(raw_data, element.data.data(), length)); |
| 633 } | 634 } |
| 634 | 635 |
| (...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2393 | 2394 |
| 2394 TEST_F(DevToolsAgentTest, RuntimeEnableForcesContextsAfterNavigation) { | 2395 TEST_F(DevToolsAgentTest, RuntimeEnableForcesContextsAfterNavigation) { |
| 2395 Attach(); | 2396 Attach(); |
| 2396 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Runtime.enable\"}"); | 2397 DispatchDevToolsMessage("{\"id\":1,\"method\":\"Runtime.enable\"}"); |
| 2397 EXPECT_EQ(0, CountNotifications("Runtime.executionContextCreated")); | 2398 EXPECT_EQ(0, CountNotifications("Runtime.executionContextCreated")); |
| 2398 LoadHTML("<body>page<iframe></iframe></body>"); | 2399 LoadHTML("<body>page<iframe></iframe></body>"); |
| 2399 EXPECT_EQ(2, CountNotifications("Runtime.executionContextCreated")); | 2400 EXPECT_EQ(2, CountNotifications("Runtime.executionContextCreated")); |
| 2400 } | 2401 } |
| 2401 | 2402 |
| 2402 } // namespace content | 2403 } // namespace content |
| OLD | NEW |