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

Side by Side Diff: ios/web/navigation/window_location_inttest.mm

Issue 2597133003: Created a test for window.location.reload(). (Closed)
Patch Set: Created 3 years, 12 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "base/mac/bind_objc_block.h" 5 #import "base/mac/bind_objc_block.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/test/ios/wait_util.h" 9 #include "base/test/ios/wait_util.h"
10 #include "ios/web/public/navigation_item.h" 10 #include "ios/web/public/navigation_item.h"
(...skipping 23 matching lines...) Expand all
34 // present on the page. This string is added to the page in the onload event 34 // present on the page. This string is added to the page in the onload event
35 // and is removed once a button is tapped. Verifying that the onload text is 35 // and is removed once a button is tapped. Verifying that the onload text is
36 // visible after tapping a button is equivalent to checking that a load has 36 // visible after tapping a button is equivalent to checking that a load has
37 // occurred as the result of the button tap. 37 // occurred as the result of the button tap.
38 const char kWindowLocationTestURL[] = 38 const char kWindowLocationTestURL[] =
39 "http://ios/testing/data/http_server_files/window_location.html"; 39 "http://ios/testing/data/http_server_files/window_location.html";
40 40
41 // Button IDs used in the window.location test page. 41 // Button IDs used in the window.location test page.
42 const char kWindowLocationAssignID[] = "location-assign"; 42 const char kWindowLocationAssignID[] = "location-assign";
43 const char kWindowLocationReplaceID[] = "location-replace"; 43 const char kWindowLocationReplaceID[] = "location-replace";
44 const char kWindowLocationReloadID[] = "location-reload";
44 45
45 // JavaScript functions on the window.location test page. 46 // JavaScript functions on the window.location test page.
46 const char kUpdateURLScriptFormat[] = "updateUrlToLoadText('%s')"; 47 const char kUpdateURLScriptFormat[] = "updateUrlToLoadText('%s')";
47 const char kGetURLScript[] = "getUrl()"; 48 const char kGetURLScript[] = "getUrl()";
48 const char kOnLoadCheckScript[] = "isOnLoadTextVisible()"; 49 const char kOnLoadCheckScript[] = "isOnLoadTextVisible()";
49 50
50 // URL of a sample file-based page. 51 // URL of a sample file-based page.
51 const char kSampleFileBasedURL[] = 52 const char kSampleFileBasedURL[] =
52 "http://ios/testing/data/http_server_files/chromium_logo_page.html"; 53 "http://ios/testing/data/http_server_files/chromium_logo_page.html";
53 54
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 ExpectPageLoad(about_blank); 279 ExpectPageLoad(about_blank);
279 SetWindowLocationUrl(unresolvable_url); 280 SetWindowLocationUrl(unresolvable_url);
280 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(), 281 ASSERT_TRUE(web::test::TapWebViewElementWithId(web_state(),
281 kWindowLocationReplaceID)); 282 kWindowLocationReplaceID));
282 WaitForPageToLoad(); 283 WaitForPageToLoad();
283 284
284 // Verify that about:blank was actually loaded. 285 // Verify that about:blank was actually loaded.
285 EXPECT_EQ(about_blank, 286 EXPECT_EQ(about_blank,
286 navigation_manager()->GetLastCommittedItem()->GetURL()); 287 navigation_manager()->GetLastCommittedItem()->GetURL());
287 } 288 }
289
290 // Tests that calling window.location.reload() causes an onload event to occur.
291 TEST_F(WindowLocationTest, WindowLocationReload) {
292 // Tap the window.location.reload() button.
293 ExpectPageLoad(window_location_url());
294 ASSERT_TRUE(
295 web::test::TapWebViewElementWithId(web_state(), kWindowLocationReloadID));
296 WaitForPageToLoad();
297
298 // Verify that |kOnLoadText| is displayed and that no additional
299 // NavigationItems are added.
300 EXPECT_TRUE(IsOnLoadTextVisible());
301 EXPECT_EQ(1, (NSInteger)navigation_manager()->GetItemCount());
Eugene But (OOO till 7-30) 2016/12/23 01:57:34 Please don't use C-style casting, also this would
kkhorimoto 2017/01/20 00:38:20 Done.
302 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698