Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: content/browser/devtools/protocol/devtools_protocol_browsertest.cc

Issue 2956423003: [DevTools] Provide Target.targetInfoChanged notification (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 ->GetController() 1604 ->GetController()
1605 .GetLastCommittedEntry() 1605 .GetLastCommittedEntry()
1606 ->GetURL()); 1606 ->GetURL());
1607 } 1607 }
1608 1608
1609 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) { 1609 IN_PROC_BROWSER_TEST_F(DevToolsProtocolTest, TargetDiscovery) {
1610 std::string temp; 1610 std::string temp;
1611 std::set<std::string> ids; 1611 std::set<std::string> ids;
1612 std::unique_ptr<base::DictionaryValue> command_params; 1612 std::unique_ptr<base::DictionaryValue> command_params;
1613 std::unique_ptr<base::DictionaryValue> params; 1613 std::unique_ptr<base::DictionaryValue> params;
1614 bool is_attached;
1614 1615
1615 ASSERT_TRUE(embedded_test_server()->Start()); 1616 ASSERT_TRUE(embedded_test_server()->Start());
1616 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html"); 1617 GURL first_url = embedded_test_server()->GetURL("/devtools/navigation.html");
1617 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1); 1618 NavigateToURLBlockUntilNavigationsComplete(shell(), first_url, 1);
1618 1619
1619 GURL second_url = embedded_test_server()->GetURL("/devtools/navigation.html"); 1620 GURL second_url = embedded_test_server()->GetURL("/devtools/navigation.html");
1620 Shell* second = CreateBrowser(); 1621 Shell* second = CreateBrowser();
1621 NavigateToURLBlockUntilNavigationsComplete(second, second_url, 1); 1622 NavigateToURLBlockUntilNavigationsComplete(second, second_url, 1);
1622 1623
1623 Attach(); 1624 Attach();
1625 int attached_count = 0;
1624 command_params.reset(new base::DictionaryValue()); 1626 command_params.reset(new base::DictionaryValue());
1625 command_params->SetBoolean("discover", true); 1627 command_params->SetBoolean("discover", true);
1626 SendCommand("Target.setDiscoverTargets", std::move(command_params), true); 1628 SendCommand("Target.setDiscoverTargets", std::move(command_params), true);
1627 params = WaitForNotification("Target.targetCreated", true); 1629 params = WaitForNotification("Target.targetCreated", true);
1628 EXPECT_TRUE(params->GetString("targetInfo.type", &temp)); 1630 EXPECT_TRUE(params->GetString("targetInfo.type", &temp));
1629 EXPECT_EQ("page", temp); 1631 EXPECT_EQ("page", temp);
1632 EXPECT_TRUE(params->GetBoolean("targetInfo.attached", &is_attached));
1633 attached_count += is_attached ? 1 : 0;
1630 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp)); 1634 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp));
1631 EXPECT_TRUE(ids.find(temp) == ids.end()); 1635 EXPECT_TRUE(ids.find(temp) == ids.end());
1632 ids.insert(temp); 1636 ids.insert(temp);
1633 params = WaitForNotification("Target.targetCreated", true); 1637 params = WaitForNotification("Target.targetCreated", true);
1634 EXPECT_TRUE(params->GetString("targetInfo.type", &temp)); 1638 EXPECT_TRUE(params->GetString("targetInfo.type", &temp));
1635 EXPECT_EQ("page", temp); 1639 EXPECT_EQ("page", temp);
1640 EXPECT_TRUE(params->GetBoolean("targetInfo.attached", &is_attached));
1641 attached_count += is_attached ? 1 : 0;
1636 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp)); 1642 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp));
1637 EXPECT_TRUE(ids.find(temp) == ids.end()); 1643 EXPECT_TRUE(ids.find(temp) == ids.end());
1638 ids.insert(temp); 1644 ids.insert(temp);
1639 EXPECT_TRUE(notifications_.empty()); 1645 EXPECT_TRUE(notifications_.empty());
1646 EXPECT_EQ(1, attached_count);
1640 1647
1641 GURL third_url = embedded_test_server()->GetURL("/devtools/navigation.html"); 1648 GURL third_url = embedded_test_server()->GetURL("/devtools/navigation.html");
1642 Shell* third = CreateBrowser(); 1649 Shell* third = CreateBrowser();
1643 NavigateToURLBlockUntilNavigationsComplete(third, third_url, 1); 1650 NavigateToURLBlockUntilNavigationsComplete(third, third_url, 1);
1644 params = WaitForNotification("Target.targetCreated", true); 1651 params = WaitForNotification("Target.targetCreated", true);
1645 EXPECT_TRUE(params->GetString("targetInfo.type", &temp)); 1652 EXPECT_TRUE(params->GetString("targetInfo.type", &temp));
1646 EXPECT_EQ("page", temp); 1653 EXPECT_EQ("page", temp);
1647 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp)); 1654 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp));
1648 EXPECT_TRUE(ids.find(temp) == ids.end()); 1655 EXPECT_TRUE(ids.find(temp) == ids.end());
1656 EXPECT_TRUE(params->GetBoolean("targetInfo.attached", &is_attached));
1657 EXPECT_FALSE(is_attached);
1649 std::string attached_id = temp; 1658 std::string attached_id = temp;
1650 ids.insert(temp); 1659 ids.insert(temp);
1651 EXPECT_TRUE(notifications_.empty()); 1660 EXPECT_TRUE(notifications_.empty());
1652 1661
1653 second->Close(); 1662 second->Close();
1654 second = nullptr; 1663 second = nullptr;
1655 params = WaitForNotification("Target.targetDestroyed", true); 1664 params = WaitForNotification("Target.targetDestroyed", true);
1656 EXPECT_TRUE(params->GetString("targetId", &temp)); 1665 EXPECT_TRUE(params->GetString("targetId", &temp));
1657 EXPECT_TRUE(ids.find(temp) != ids.end()); 1666 EXPECT_TRUE(ids.find(temp) != ids.end());
1658 ids.erase(temp); 1667 ids.erase(temp);
1659 EXPECT_TRUE(notifications_.empty()); 1668 EXPECT_TRUE(notifications_.empty());
1660 1669
1661 command_params.reset(new base::DictionaryValue()); 1670 command_params.reset(new base::DictionaryValue());
1662 command_params->SetString("targetId", attached_id); 1671 command_params->SetString("targetId", attached_id);
1663 SendCommand("Target.attachToTarget", std::move(command_params), true); 1672 SendCommand("Target.attachToTarget", std::move(command_params), true);
1673 params = WaitForNotification("Target.targetInfoChanged", true);
1674 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp));
1675 EXPECT_EQ(attached_id, temp);
1676 EXPECT_TRUE(params->GetBoolean("targetInfo.attached", &is_attached));
1677 EXPECT_TRUE(is_attached);
1664 params = WaitForNotification("Target.attachedToTarget", true); 1678 params = WaitForNotification("Target.attachedToTarget", true);
1665 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp)); 1679 EXPECT_TRUE(params->GetString("targetInfo.targetId", &temp));
1666 EXPECT_EQ(attached_id, temp); 1680 EXPECT_EQ(attached_id, temp);
1667 EXPECT_TRUE(notifications_.empty()); 1681 EXPECT_TRUE(notifications_.empty());
1668 1682
1669 command_params.reset(new base::DictionaryValue()); 1683 command_params.reset(new base::DictionaryValue());
1670 command_params->SetBoolean("discover", false); 1684 command_params->SetBoolean("discover", false);
1671 SendCommand("Target.setDiscoverTargets", std::move(command_params), true); 1685 SendCommand("Target.setDiscoverTargets", std::move(command_params), true);
1672 EXPECT_TRUE(notifications_.empty()); 1686 EXPECT_TRUE(notifications_.empty());
1673 1687
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 EXPECT_EQ("polyglottal", value); 1844 EXPECT_EQ("polyglottal", value);
1831 found++; 1845 found++;
1832 } else { 1846 } else {
1833 FAIL(); 1847 FAIL();
1834 } 1848 }
1835 } 1849 }
1836 EXPECT_EQ(2u, found); 1850 EXPECT_EQ(2u, found);
1837 } 1851 }
1838 1852
1839 } // namespace content 1853 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698