Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / common / mac / app_mode_chrome_locator_unittest.mm
blob50e98bfce8c2aa7163b5ea57874c1b20ef4be46d
1 // Copyright (c) 2012 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.
5 #import "chrome/common/mac/app_mode_chrome_locator.h"
7 #include <CoreFoundation/CoreFoundation.h>
9 #include "base/file_util.h"
10 #include "base/files/file_path.h"
11 #include "base/files/scoped_temp_dir.h"
12 #include "base/path_service.h"
13 #include "chrome/common/chrome_constants.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 namespace {
18 // Return the path to the Chrome/Chromium app bundle compiled along with the
19 // test executable.
20 void GetChromeBundlePath(base::FilePath* chrome_bundle) {
21   base::FilePath path;
22   PathService::Get(base::DIR_EXE, &path);
23   path = path.Append(chrome::kBrowserProcessExecutableNameChromium);
24   path = path.ReplaceExtension(base::FilePath::StringType("app"));
25   *chrome_bundle = path;
28 }  // namespace
30 TEST(ChromeLocatorTest, FindBundle) {
31   base::FilePath finder_bundle_path;
32   EXPECT_TRUE(
33       app_mode::FindBundleById(@"com.apple.finder", &finder_bundle_path));
34   EXPECT_TRUE(base::DirectoryExists(finder_bundle_path));
37 TEST(ChromeLocatorTest, FindNonExistentBundle) {
38   base::FilePath dummy;
39   EXPECT_FALSE(app_mode::FindBundleById(@"this.doesnt.exist", &dummy));
42 TEST(ChromeLocatorTest, GetNonExistentBundleInfo) {
43   base::ScopedTempDir temp_dir;
44   ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
46   base::string16 raw_version;
47   base::FilePath version_path;
48   base::FilePath framework_path;
49   EXPECT_FALSE(app_mode::GetChromeBundleInfo(temp_dir.path(),
50       &raw_version, &version_path, &framework_path));
53 TEST(ChromeLocatorTest, GetChromeBundleInfo) {
54   using app_mode::GetChromeBundleInfo;
56   base::FilePath chrome_bundle_path;
57   GetChromeBundlePath(&chrome_bundle_path);
58   ASSERT_TRUE(base::DirectoryExists(chrome_bundle_path));
60   base::string16 raw_version;
61   base::FilePath version_path;
62   base::FilePath framework_path;
63   EXPECT_TRUE(GetChromeBundleInfo(chrome_bundle_path,
64       &raw_version, &version_path, &framework_path));
65   EXPECT_GT(raw_version.size(), 0U);
66   EXPECT_TRUE(base::DirectoryExists(version_path));
67   EXPECT_TRUE(base::PathExists(framework_path));