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

Side by Side Diff: headless/lib/headless_browser_browsertest.cc

Issue 2778983002: Fix browser tests on Mac (Closed)
Patch Set: fixed comment nit Created 3 years, 8 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 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 #include <memory> 5 #include <memory>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_enumerator.h" 8 #include "base/files/file_enumerator.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, DefaultSizes) { 346 IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, DefaultSizes) {
347 HeadlessBrowserContext* browser_context = 347 HeadlessBrowserContext* browser_context =
348 browser()->CreateBrowserContextBuilder().Build(); 348 browser()->CreateBrowserContextBuilder().Build();
349 349
350 HeadlessWebContents* web_contents = 350 HeadlessWebContents* web_contents =
351 browser_context->CreateWebContentsBuilder().Build(); 351 browser_context->CreateWebContentsBuilder().Build();
352 352
353 HeadlessBrowser::Options::Builder builder; 353 HeadlessBrowser::Options::Builder builder;
354 const HeadlessBrowser::Options kDefaultOptions = builder.Build(); 354 const HeadlessBrowser::Options kDefaultOptions = builder.Build();
355 355
356 int screen_width;
357 int screen_height;
358 int window_width; 356 int window_width;
359 int window_height; 357 int window_height;
360 358
359 #if !defined(OS_MACOSX)
360 // There is no concept of screen on Mac, so this part of the test should
Sami 2017/03/28 13:11:59 Would it be more accurate to say we don't override
dvallet 2017/03/29 05:16:27 Done. Yes, that's more accurate, thanks!
361 // not run.
362 int screen_width;
363 int screen_height;
361 EXPECT_TRUE(EvaluateScript(web_contents, "screen.width") 364 EXPECT_TRUE(EvaluateScript(web_contents, "screen.width")
362 ->GetResult() 365 ->GetResult()
363 ->GetValue() 366 ->GetValue()
364 ->GetAsInteger(&screen_width)); 367 ->GetAsInteger(&screen_width));
365 EXPECT_TRUE(EvaluateScript(web_contents, "screen.height") 368 EXPECT_TRUE(EvaluateScript(web_contents, "screen.height")
366 ->GetResult() 369 ->GetResult()
367 ->GetValue() 370 ->GetValue()
368 ->GetAsInteger(&screen_height)); 371 ->GetAsInteger(&screen_height));
372 EXPECT_EQ(kDefaultOptions.window_size.width(), screen_width);
373 EXPECT_EQ(kDefaultOptions.window_size.height(), screen_height);
374 #endif // !defined(OS_MACOSX)
369 EXPECT_TRUE(EvaluateScript(web_contents, "window.innerWidth") 375 EXPECT_TRUE(EvaluateScript(web_contents, "window.innerWidth")
370 ->GetResult() 376 ->GetResult()
371 ->GetValue() 377 ->GetValue()
372 ->GetAsInteger(&window_width)); 378 ->GetAsInteger(&window_width));
373 EXPECT_TRUE(EvaluateScript(web_contents, "window.innerHeight") 379 EXPECT_TRUE(EvaluateScript(web_contents, "window.innerHeight")
374 ->GetResult() 380 ->GetResult()
375 ->GetValue() 381 ->GetValue()
376 ->GetAsInteger(&window_height)); 382 ->GetAsInteger(&window_height));
377 383
378 EXPECT_EQ(kDefaultOptions.window_size.width(), screen_width);
379 EXPECT_EQ(kDefaultOptions.window_size.height(), screen_height);
380 EXPECT_EQ(kDefaultOptions.window_size.width(), window_width); 384 EXPECT_EQ(kDefaultOptions.window_size.width(), window_width);
381 EXPECT_EQ(kDefaultOptions.window_size.height(), window_height); 385 EXPECT_EQ(kDefaultOptions.window_size.height(), window_height);
382 } 386 }
383 387
384 namespace { 388 namespace {
385 389
386 // True if the request method is "safe" (per section 4.2.1 of RFC 7231). 390 // True if the request method is "safe" (per section 4.2.1 of RFC 7231).
387 bool IsMethodSafe(const std::string& method) { 391 bool IsMethodSafe(const std::string& method) {
388 return method == "GET" || method == "HEAD" || method == "OPTIONS" || 392 return method == "GET" || method == "HEAD" || method == "OPTIONS" ||
389 method == "TRACE"; 393 method == "TRACE";
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 751
748 web_contents_->RemoveObserver(this); 752 web_contents_->RemoveObserver(this);
749 web_contents_->Close(); 753 web_contents_->Close();
750 web_contents_ = nullptr; 754 web_contents_ = nullptr;
751 755
752 browser_context_->Close(); 756 browser_context_->Close();
753 browser_context_ = nullptr; 757 browser_context_ = nullptr;
754 } 758 }
755 759
756 } // namespace headless 760 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698