diff options
author | Chris Goldthorpe | 2009-06-23 00:34:50 +0000 |
---|---|---|
committer | Chris Goldthorpe | 2009-06-23 00:34:50 +0000 |
commit | e0595fa6e9371d88cd981d2021a09503055771b9 (patch) | |
tree | fc166e21831917f91e665f3e414d541edcfc81e6 /org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests | |
parent | 8657a1ce7e50b901a9a2284e7e5e609b4830e2f9 (diff) | |
download | eclipse.platform.ua-e0595fa6e9371d88cd981d2021a09503055771b9.tar.gz eclipse.platform.ua-e0595fa6e9371d88cd981d2021a09503055771b9.tar.xz eclipse.platform.ua-e0595fa6e9371d88cd981d2021a09503055771b9.zip |
Bug 280810 [CheatSheet] Adding a parent category to a cheat sheet category removes cheatsheets from this category
Diffstat (limited to 'org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests')
2 files changed, 96 insertions, 0 deletions
diff --git a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/AllOtherCheatSheetTests.java b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/AllOtherCheatSheetTests.java index da03fd191..3e6e944e4 100644 --- a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/AllOtherCheatSheetTests.java +++ b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/AllOtherCheatSheetTests.java @@ -27,6 +27,7 @@ public class AllOtherCheatSheetTests { suite.addTestSuite(TestEscape.class); suite.addTestSuite(TestCheatSheetManager.class); suite.addTestSuite(TestCheatSheetCollection.class); + suite.addTestSuite(TestCheatSheetCategories.class); //$JUnit-END$ return suite; } diff --git a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/TestCheatSheetCategories.java b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/TestCheatSheetCategories.java new file mode 100644 index 000000000..8cd83ceb4 --- /dev/null +++ b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/other/TestCheatSheetCategories.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2009 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.ua.tests.cheatsheet.other; + +import junit.framework.TestCase; + +import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetCollectionElement; +import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetElement; +import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetRegistryReader; + +public class TestCheatSheetCategories extends TestCase { + + private static final String TEST_CATEGORY = "org.eclipse.ua.tests.cheatsheet.cheatSheetsTestCat"; + + public void testForCollection() { + CheatSheetCollectionElement cheatSheets = + (CheatSheetCollectionElement)CheatSheetRegistryReader.getInstance().getCheatSheets(); + Object[] subCategories = cheatSheets.getChildren(); + for (int i = 0; i < subCategories.length; i++) { + assertTrue(subCategories[i] instanceof CheatSheetCollectionElement); + } + } + + public void testFindTestCategory() { + CheatSheetCollectionElement cheatSheets = + (CheatSheetCollectionElement)CheatSheetRegistryReader.getInstance().getCheatSheets(); + CheatSheetCollectionElement testCat = findChildCategory(cheatSheets, TEST_CATEGORY); + assertNotNull("Cannot find category org.eclipse.ua.tests.cheatsheet.cheatSheetsTestCat", + testCat); + } + + public void testFindQualifiedSubcategory() { + CheatSheetCollectionElement cheatSheets = + (CheatSheetCollectionElement)CheatSheetRegistryReader.getInstance().getCheatSheets(); + CheatSheetCollectionElement testCat = findChildCategory(cheatSheets, TEST_CATEGORY); + CheatSheetCollectionElement subCat = findChildCategory(testCat, + "org.eclipse.ua.tests.subcategory"); + assertNotNull(subCat); + } + + public void testFindCsInUnqualifiedSubcategory() { + CheatSheetCollectionElement cheatSheets = + (CheatSheetCollectionElement)CheatSheetRegistryReader.getInstance().getCheatSheets(); + CheatSheetCollectionElement testCat = findChildCategory(cheatSheets, TEST_CATEGORY); + CheatSheetCollectionElement subCat = findChildCategory(testCat, + "org.eclipse.ua.tests.subcategory"); + CheatSheetElement unqual = findCheatsheet(subCat, + "org.eclipse.ua.tests.cheatsheet.subcategory.simple"); + assertNotNull(unqual); + } + + public void testFindCsInQualifiedSubcategory() { + CheatSheetCollectionElement cheatSheets = + (CheatSheetCollectionElement)CheatSheetRegistryReader.getInstance().getCheatSheets(); + CheatSheetCollectionElement testCat = findChildCategory(cheatSheets, TEST_CATEGORY); + CheatSheetCollectionElement subCat = findChildCategory(testCat, + "org.eclipse.ua.tests.subcategory"); + CheatSheetElement qual = findCheatsheet(subCat, + "org.eclipse.ua.tests.cheatsheet.subcategory.qualified"); + assertNotNull(qual); + } + + private CheatSheetCollectionElement findChildCategory( + CheatSheetCollectionElement collection, String id) { + Object[] subCategories = collection.getChildren(); + for (int i = 0; i < subCategories.length; i++) { + CheatSheetCollectionElement child = (CheatSheetCollectionElement)subCategories[i]; + if (child.getId().equals(id)) { + return child; + } + } + return null; + } + private CheatSheetElement findCheatsheet( + CheatSheetCollectionElement collection, String id) { + Object[] cheatSheets = collection.getCheatSheets(); + for (int i = 0; i < cheatSheets.length; i++) { + CheatSheetElement child = (CheatSheetElement)cheatSheets[i]; + if (child.getID().equals(id)) { + return child; + } + } + return null; + } + +} |