summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_test_util.cc
blob: 5dfa9a64535f7444f5b61ac11993b20c2e7a2854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2012 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.

#include "base/values.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/extension_test_util.h"
#include "testing/gtest/include/gtest/gtest.h"

using extensions::Extension;

namespace extension_test_util {

std::string MakeId(std::string seed) {
  std::string result;
  bool success = Extension::GenerateId(seed, &result);
  EXPECT_TRUE(success);
  EXPECT_FALSE(result.empty());
  EXPECT_TRUE(Extension::IdIsValid(result));
  return result;
}

scoped_refptr<Extension> CreateExtensionWithID(std::string id) {
  DictionaryValue values;
  values.SetString(extension_manifest_keys::kName, "test");
  values.SetString(extension_manifest_keys::kVersion, "0.1");
  std::string error;
  return Extension::Create(FilePath(), Extension::INTERNAL, values,
                           Extension::NO_FLAGS, id, &error);
}

}  // namespace extension_test_util