OLD | NEW |
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 "chrome/browser/shell_integration_linux.h" | 5 #include "chrome/browser/shell_integration_linux.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstdlib> | 8 #include <cstdlib> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 } test_cases[] = { | 410 } test_cases[] = { |
411 { FPL("http___foo_.desktop"), "http://foo" }, | 411 { FPL("http___foo_.desktop"), "http://foo" }, |
412 { FPL("http___foo_bar_.desktop"), "http://foo/bar/" }, | 412 { FPL("http___foo_bar_.desktop"), "http://foo/bar/" }, |
413 { FPL("http___foo_bar_a=b&c=d.desktop"), "http://foo/bar?a=b&c=d" }, | 413 { FPL("http___foo_bar_a=b&c=d.desktop"), "http://foo/bar?a=b&c=d" }, |
414 | 414 |
415 // Now we're starting to be more evil... | 415 // Now we're starting to be more evil... |
416 { FPL("http___foo_.desktop"), "http://foo/bar/baz/../../../../../" }, | 416 { FPL("http___foo_.desktop"), "http://foo/bar/baz/../../../../../" }, |
417 { FPL("http___foo_.desktop"), "http://foo/bar/././../baz/././../" }, | 417 { FPL("http___foo_.desktop"), "http://foo/bar/././../baz/././../" }, |
418 { FPL("http___.._.desktop"), "http://../../../../" }, | 418 { FPL("http___.._.desktop"), "http://../../../../" }, |
419 }; | 419 }; |
420 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { | 420 for (size_t i = 0; i < arraysize(test_cases); i++) { |
421 EXPECT_EQ(std::string(chrome::kBrowserProcessExecutableName) + "-" + | 421 EXPECT_EQ(std::string(chrome::kBrowserProcessExecutableName) + "-" + |
422 test_cases[i].path, | 422 test_cases[i].path, |
423 GetWebShortcutFilename(GURL(test_cases[i].url)).value()) << | 423 GetWebShortcutFilename(GURL(test_cases[i].url)).value()) << |
424 " while testing " << test_cases[i].url; | 424 " while testing " << test_cases[i].url; |
425 } | 425 } |
426 } | 426 } |
427 | 427 |
428 TEST(ShellIntegrationTest, GetDesktopFileContents) { | 428 TEST(ShellIntegrationTest, GetDesktopFileContents) { |
429 const base::FilePath kChromeExePath("/opt/google/chrome/google-chrome"); | 429 const base::FilePath kChromeExePath("/opt/google/chrome/google-chrome"); |
430 const struct { | 430 const struct { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 "Name=Innocent Title\n" | 549 "Name=Innocent Title\n" |
550 "Exec=/opt/google/chrome/google-chrome " | 550 "Exec=/opt/google/chrome/google-chrome " |
551 "--app=http://evil.com/evil%20%7C%20cat%20%60echo%20ownz0red" | 551 "--app=http://evil.com/evil%20%7C%20cat%20%60echo%20ownz0red" |
552 "%60%20%3E/dev/null\n" | 552 "%60%20%3E/dev/null\n" |
553 "Icon=chrome-http__evil.com_evil\n" | 553 "Icon=chrome-http__evil.com_evil\n" |
554 "StartupWMClass=evil.com__evil%20%7C%20cat%20%60echo%20ownz0red" | 554 "StartupWMClass=evil.com__evil%20%7C%20cat%20%60echo%20ownz0red" |
555 "%60%20%3E_dev_null\n" | 555 "%60%20%3E_dev_null\n" |
556 }, | 556 }, |
557 }; | 557 }; |
558 | 558 |
559 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { | 559 for (size_t i = 0; i < arraysize(test_cases); i++) { |
560 SCOPED_TRACE(i); | 560 SCOPED_TRACE(i); |
561 EXPECT_EQ( | 561 EXPECT_EQ( |
562 test_cases[i].expected_output, | 562 test_cases[i].expected_output, |
563 GetDesktopFileContents( | 563 GetDesktopFileContents( |
564 kChromeExePath, | 564 kChromeExePath, |
565 web_app::GenerateApplicationNameFromURL(GURL(test_cases[i].url)), | 565 web_app::GenerateApplicationNameFromURL(GURL(test_cases[i].url)), |
566 GURL(test_cases[i].url), | 566 GURL(test_cases[i].url), |
567 std::string(), | 567 std::string(), |
568 base::ASCIIToUTF16(test_cases[i].title), | 568 base::ASCIIToUTF16(test_cases[i].title), |
569 test_cases[i].icon_name, | 569 test_cases[i].icon_name, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 "Type=Directory\n" | 624 "Type=Directory\n" |
625 "Name=Chrome Apps\n" | 625 "Name=Chrome Apps\n" |
626 #if defined(GOOGLE_CHROME_BUILD) | 626 #if defined(GOOGLE_CHROME_BUILD) |
627 "Icon=google-chrome\n" | 627 "Icon=google-chrome\n" |
628 #else | 628 #else |
629 "Icon=chromium-browser\n" | 629 "Icon=chromium-browser\n" |
630 #endif | 630 #endif |
631 }, | 631 }, |
632 }; | 632 }; |
633 | 633 |
634 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { | 634 for (size_t i = 0; i < arraysize(test_cases); i++) { |
635 SCOPED_TRACE(i); | 635 SCOPED_TRACE(i); |
636 EXPECT_EQ(test_cases[i].expected_output, | 636 EXPECT_EQ(test_cases[i].expected_output, |
637 GetDirectoryFileContents(base::ASCIIToUTF16(test_cases[i].title), | 637 GetDirectoryFileContents(base::ASCIIToUTF16(test_cases[i].title), |
638 test_cases[i].icon_name)); | 638 test_cases[i].icon_name)); |
639 } | 639 } |
640 } | 640 } |
641 | 641 |
642 } // namespace shell_integration_linux | 642 } // namespace shell_integration_linux |
OLD | NEW |