<commit_before>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Download utility test for Mac OS X.

#include "base/path_service.h"
#include "base/sys_string_conversions.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
#import "chrome/browser/ui/cocoa/download/download_util_mac.h"
#include "chrome/common/chrome_paths.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"

namespace {

class DownloadUtilMacTest : public CocoaTest {
 public:
  DownloadUtilMacTest() {
    pasteboard_ = [NSPasteboard pasteboardWithUniqueName];
  }

  virtual ~DownloadUtilMacTest() {
    [pasteboard_ releaseGlobally];
  }

  NSPasteboard* const pasteboard() { return pasteboard_; }

 private:
  NSPasteboard* pasteboard_;
};

// Ensure adding files to the pasteboard methods works as expected.
TEST_F(DownloadUtilMacTest, AddFileToPasteboardTest) {
  // Get a download test file for addition to the pasteboard.
  FilePath testPath;
  ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &testPath));
  FilePath testFile(FILE_PATH_LITERAL("download-test1.lib"));
  testPath = testPath.Append(testFile);

  // Add a test file to the pasteboard via the download_util method.
  download_util::AddFileToPasteboard(pasteboard(), testPath);

  // Test to see that the object type for dragging files is available.
  NSArray* types =  [NSArray arrayWithObject:NSFilenamesPboardType];
  NSString* available = [pasteboard() availableTypeFromArray:types];
  EXPECT_TRUE(available != nil);

  // Ensure the path is what we expect.
  NSArray* files = [pasteboard() propertyListForType:NSFilenamesPboardType];
  ASSERT_TRUE(files != nil);
  NSString* expectedPath = [files objectAtIndex:0];
  NSString* realPath = base::SysWideToNSString(testPath.ToWStringHack());
  EXPECT_NSEQ(expectedPath, realPath);
}

}  // namespace
<commit_msg>mac: remove a ToWStringHack<commit_after>// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Download utility test for Mac OS X.

#include "base/path_service.h"
#include "base/sys_string_conversions.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
#import "chrome/browser/ui/cocoa/download/download_util_mac.h"
#include "chrome/common/chrome_paths.h"
#include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h"
#include "testing/platform_test.h"

namespace {

class DownloadUtilMacTest : public CocoaTest {
 public:
  DownloadUtilMacTest() {
    pasteboard_ = [NSPasteboard pasteboardWithUniqueName];
  }

  virtual ~DownloadUtilMacTest() {
    [pasteboard_ releaseGlobally];
  }

  NSPasteboard* const pasteboard() { return pasteboard_; }

 private:
  NSPasteboard* pasteboard_;
};

// Ensure adding files to the pasteboard methods works as expected.
TEST_F(DownloadUtilMacTest, AddFileToPasteboardTest) {
  // Get a download test file for addition to the pasteboard.
  FilePath testPath;
  ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &testPath));
  FilePath testFile(FILE_PATH_LITERAL("download-test1.lib"));
  testPath = testPath.Append(testFile);

  // Add a test file to the pasteboard via the download_util method.
  download_util::AddFileToPasteboard(pasteboard(), testPath);

  // Test to see that the object type for dragging files is available.
  NSArray* types =  [NSArray arrayWithObject:NSFilenamesPboardType];
  NSString* available = [pasteboard() availableTypeFromArray:types];
  EXPECT_TRUE(available != nil);

  // Ensure the path is what we expect.
  NSArray* files = [pasteboard() propertyListForType:NSFilenamesPboardType];
  ASSERT_TRUE(files != nil);
  NSString* expectedPath = [files objectAtIndex:0];
  NSString* realPath = base::SysUTF8ToNSString(testPath.value());
  EXPECT_NSEQ(expectedPath, realPath);
}

}  // namespace

{'fraction_non_alphanumeric': 0.10475, 'fraction_numerical': 0.00325, 'mean_word_length': 5.136503067484663, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4440268', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1242, 'n_words': 327}