Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / developer_private / developer_private_apitest.cc
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.
4
5 #include <map>
6
7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/common/chrome_switches.h"
9
10 using extensions::Extension;
11 using extensions::Manifest;
12
13 class DeveloperPrivateApiTest : public ExtensionApiTest {
14  public:
15   virtual void LoadExtensions() {
16     base::FilePath base_dir = test_data_dir_.AppendASCII("developer");
17     LoadNamedExtension(base_dir, "hosted_app");
18   }
19
20  protected:
21   void LoadNamedExtension(const base::FilePath& path,
22                           const std::string& name) {
23     const Extension* extension = LoadExtension(path.AppendASCII(name));
24     ASSERT_TRUE(extension);
25     extension_name_to_ids_[name] = extension->id();
26   }
27
28   void InstallNamedExtension(const base::FilePath& path,
29                              const std::string& name,
30                              Manifest::Location install_source) {
31     const Extension* extension = InstallExtension(path.AppendASCII(name), 1,
32                                                   install_source);
33     ASSERT_TRUE(extension);
34     extension_name_to_ids_[name] = extension->id();
35   }
36
37   std::map<std::string, std::string> extension_name_to_ids_;
38 };
39
40 IN_PROC_BROWSER_TEST_F(DeveloperPrivateApiTest, Basics) {
41   LoadExtensions();
42
43   base::FilePath basedir = test_data_dir_.AppendASCII("developer");
44   InstallNamedExtension(basedir, "packaged_app", Manifest::INTERNAL);
45
46   InstallNamedExtension(basedir, "simple_extension", Manifest::INTERNAL);
47
48   ASSERT_TRUE(RunPlatformAppTestWithFlags(
49       "developer/test", kFlagLoadAsComponent));
50 }