OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
28 #include "chrome/test/base/browser_with_test_window_test.h" | 28 #include "chrome/test/base/browser_with_test_window_test.h" |
29 #include "chrome/test/base/testing_pref_service.h" | 29 #include "chrome/test/base/testing_pref_service.h" |
30 #include "chrome/test/base/testing_profile.h" | 30 #include "chrome/test/base/testing_profile.h" |
31 #include "content/public/test/test_browser_thread.h" | 31 #include "content/public/test/test_browser_thread.h" |
32 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
33 #include "ui/base/models/menu_model.h" | 33 #include "ui/base/models/menu_model.h" |
34 | 34 |
35 using extensions::Extension; | 35 using extensions::Extension; |
| 36 using extensions::Manifest; |
36 | 37 |
37 namespace { | 38 namespace { |
38 const int kExpectedAppIndex = 1; | 39 const int kExpectedAppIndex = 1; |
39 const char* gmail_app_id = "pjkljhegncpnkpknbcohdijeoejaedia"; | 40 const char* gmail_app_id = "pjkljhegncpnkpknbcohdijeoejaedia"; |
40 const char* gmail_url = "https://mail.google.com/mail/u"; | 41 const char* gmail_url = "https://mail.google.com/mail/u"; |
41 } | 42 } |
42 | 43 |
43 class ChromeLauncherControllerPerAppTest : public BrowserWithTestWindowTest { | 44 class ChromeLauncherControllerPerAppTest : public BrowserWithTestWindowTest { |
44 protected: | 45 protected: |
45 ChromeLauncherControllerPerAppTest() : extension_service_(NULL) { | 46 ChromeLauncherControllerPerAppTest() : extension_service_(NULL) { |
46 } | 47 } |
47 | 48 |
48 virtual void SetUp() OVERRIDE { | 49 virtual void SetUp() OVERRIDE { |
49 BrowserWithTestWindowTest::SetUp(); | 50 BrowserWithTestWindowTest::SetUp(); |
50 | 51 |
51 DictionaryValue manifest; | 52 DictionaryValue manifest; |
52 manifest.SetString("name", "launcher controller test extension"); | 53 manifest.SetString("name", "launcher controller test extension"); |
53 manifest.SetString("version", "1"); | 54 manifest.SetString("version", "1"); |
54 manifest.SetString("description", "for testing pinned apps"); | 55 manifest.SetString("description", "for testing pinned apps"); |
55 | 56 |
56 extensions::TestExtensionSystem* extension_system( | 57 extensions::TestExtensionSystem* extension_system( |
57 static_cast<extensions::TestExtensionSystem*>( | 58 static_cast<extensions::TestExtensionSystem*>( |
58 extensions::ExtensionSystem::Get(profile()))); | 59 extensions::ExtensionSystem::Get(profile()))); |
59 extension_service_ = extension_system->CreateExtensionService( | 60 extension_service_ = extension_system->CreateExtensionService( |
60 CommandLine::ForCurrentProcess(), FilePath(), false); | 61 CommandLine::ForCurrentProcess(), FilePath(), false); |
61 | 62 |
62 std::string error; | 63 std::string error; |
63 extension1_ = Extension::Create(FilePath(), Extension::LOAD, manifest, | 64 extension1_ = Extension::Create(FilePath(), Manifest::LOAD, manifest, |
64 Extension::NO_FLAGS, | 65 Extension::NO_FLAGS, |
65 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | 66 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
66 &error); | 67 &error); |
67 extension2_ = Extension::Create(FilePath(), Extension::LOAD, manifest, | 68 extension2_ = Extension::Create(FilePath(), Manifest::LOAD, manifest, |
68 Extension::NO_FLAGS, | 69 Extension::NO_FLAGS, |
69 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", | 70 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", |
70 &error); | 71 &error); |
71 // Fake gmail extension. | 72 // Fake gmail extension. |
72 extension3_ = Extension::Create(FilePath(), Extension::LOAD, manifest, | 73 extension3_ = Extension::Create(FilePath(), Manifest::LOAD, manifest, |
73 Extension::NO_FLAGS, | 74 Extension::NO_FLAGS, |
74 gmail_app_id, | 75 gmail_app_id, |
75 &error); | 76 &error); |
76 | 77 |
77 // Fake search extension. | 78 // Fake search extension. |
78 extension4_ = Extension::Create(FilePath(), Extension::LOAD, manifest, | 79 extension4_ = Extension::Create(FilePath(), Manifest::LOAD, manifest, |
79 Extension::NO_FLAGS, | 80 Extension::NO_FLAGS, |
80 "coobgpohoikkiipiblmjeljniedjpjpf", | 81 "coobgpohoikkiipiblmjeljniedjpjpf", |
81 &error); | 82 &error); |
82 } | 83 } |
83 | 84 |
84 void InsertPrefValue(base::ListValue* pref_value, | 85 void InsertPrefValue(base::ListValue* pref_value, |
85 int index, | 86 int index, |
86 const std::string& extension_id) { | 87 const std::string& extension_id) { |
87 base::DictionaryValue* entry = new DictionaryValue(); | 88 base::DictionaryValue* entry = new DictionaryValue(); |
88 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id); | 89 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 int first_item = | 467 int first_item = |
467 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; | 468 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; |
468 menu->ActivatedAt(first_item + 3); | 469 menu->ActivatedAt(first_item + 3); |
469 } | 470 } |
470 // Now the active tab should be the second item. | 471 // Now the active tab should be the second item. |
471 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 472 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
472 } | 473 } |
473 | 474 |
474 // TODO(skuhne) Add tests for: | 475 // TODO(skuhne) Add tests for: |
475 // - V2 apps: create through item in launcher or directly | 476 // - V2 apps: create through item in launcher or directly |
OLD | NEW |