shell_content_browser_client_unittest.cc 993 B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "extensions/shell/browser/shell_content_browser_client.h"
  5. #include <string>
  6. #include "base/strings/pattern.h"
  7. #include "base/strings/string_util.h"
  8. #include "testing/gtest/include/gtest/gtest.h"
  9. namespace extensions {
  10. // Tests that the app_shell user agent looks like a Chrome user agent.
  11. TEST(ShellContentBrowserClientTest, UserAgentFormat) {
  12. ShellContentBrowserClient client(nullptr);
  13. std::string user_agent = client.GetUserAgent();
  14. // Must start with the usual Mozilla-compatibility string.
  15. EXPECT_TRUE(base::StartsWith(user_agent, "Mozilla/5.0",
  16. base::CompareCase::INSENSITIVE_ASCII))
  17. << user_agent;
  18. // Must contain a substring like "Chrome/1.2.3.4".
  19. EXPECT_TRUE(base::MatchPattern(user_agent, "*Chrome/*.*.*.*")) << user_agent;
  20. }
  21. } // namespace extensions