OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Pass into ServiceWorkerTest::StartTestFromBackgroundPage to indicate that | 44 // Pass into ServiceWorkerTest::StartTestFromBackgroundPage to indicate that |
45 // registration is expected to succeed. | 45 // registration is expected to succeed. |
46 std::string* const kExpectSuccess = nullptr; | 46 std::string* const kExpectSuccess = nullptr; |
47 | 47 |
48 void DoNothingWithBool(bool b) {} | 48 void DoNothingWithBool(bool b) {} |
49 | 49 |
50 // Returns the newly added WebContents. | 50 // Returns the newly added WebContents. |
51 content::WebContents* AddTab(Browser* browser, const GURL& url) { | 51 content::WebContents* AddTab(Browser* browser, const GURL& url) { |
52 int starting_tab_count = browser->tab_strip_model()->count(); | 52 int starting_tab_count = browser->tab_strip_model()->count(); |
53 ui_test_utils::NavigateToURLWithDisposition( | 53 ui_test_utils::NavigateToURLWithDisposition( |
54 browser, url, NEW_FOREGROUND_TAB, | 54 browser, url, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
55 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 55 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
56 int tab_count = browser->tab_strip_model()->count(); | 56 int tab_count = browser->tab_strip_model()->count(); |
57 EXPECT_EQ(starting_tab_count + 1, tab_count); | 57 EXPECT_EQ(starting_tab_count + 1, tab_count); |
58 return browser->tab_strip_model()->GetActiveWebContents(); | 58 return browser->tab_strip_model()->GetActiveWebContents(); |
59 } | 59 } |
60 | 60 |
61 class WebContentsLoadStopObserver : content::WebContentsObserver { | 61 class WebContentsLoadStopObserver : content::WebContentsObserver { |
62 public: | 62 public: |
63 explicit WebContentsLoadStopObserver(content::WebContents* web_contents) | 63 explicit WebContentsLoadStopObserver(content::WebContents* web_contents) |
64 : content::WebContentsObserver(web_contents), | 64 : content::WebContentsObserver(web_contents), |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 *error_or_null = error; | 122 *error_or_null = error; |
123 else if (!error.empty()) | 123 else if (!error.empty()) |
124 ADD_FAILURE() << "Got unexpected error " << error; | 124 ADD_FAILURE() << "Got unexpected error " << error; |
125 return extension; | 125 return extension; |
126 } | 126 } |
127 | 127 |
128 // Navigates the browser to a new tab at |url|, waits for it to load, then | 128 // Navigates the browser to a new tab at |url|, waits for it to load, then |
129 // returns it. | 129 // returns it. |
130 content::WebContents* Navigate(const GURL& url) { | 130 content::WebContents* Navigate(const GURL& url) { |
131 ui_test_utils::NavigateToURLWithDisposition( | 131 ui_test_utils::NavigateToURLWithDisposition( |
132 browser(), url, NEW_FOREGROUND_TAB, | 132 browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
133 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 133 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
134 content::WebContents* web_contents = | 134 content::WebContents* web_contents = |
135 browser()->tab_strip_model()->GetActiveWebContents(); | 135 browser()->tab_strip_model()->GetActiveWebContents(); |
136 content::WaitForLoadStop(web_contents); | 136 content::WaitForLoadStop(web_contents); |
137 return web_contents; | 137 return web_contents; |
138 } | 138 } |
139 | 139 |
140 // Navigates the browser to |url| and returns the new tab's page type. | 140 // Navigates the browser to |url| and returns the new tab's page type. |
141 content::PageType NavigateAndGetPageType(const GURL& url) { | 141 content::PageType NavigateAndGetPageType(const GURL& url) { |
142 return Navigate(url)->GetController().GetActiveEntry()->GetPageType(); | 142 return Navigate(url)->GetController().GetActiveEntry()->GetPageType(); |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 message.sender_id = "1234567890"; | 773 message.sender_id = "1234567890"; |
774 message.raw_data = "testdata"; | 774 message.raw_data = "testdata"; |
775 message.decrypted = true; | 775 message.decrypted = true; |
776 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); | 776 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); |
777 push_service()->OnMessage(app_identifier.app_id(), message); | 777 push_service()->OnMessage(app_identifier.app_id(), message); |
778 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); | 778 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); |
779 run_loop.Run(); // Wait until the message is handled by push service. | 779 run_loop.Run(); // Wait until the message is handled by push service. |
780 } | 780 } |
781 | 781 |
782 } // namespace extensions | 782 } // namespace extensions |
OLD | NEW |