Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/base.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/base.py	(revision 2750)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/base.py	(revision 2841)
@@ -11,4 +11,5 @@
 from zope.interface import Interface
 from zope.component import testing
+from zope.interface import alsoProvides
 from Testing import ZopeTestCase as ztc
 
@@ -27,5 +28,7 @@
 from quintagroup.plonegooglesitemaps.config import PROJECTNAME
 from quintagroup.plonegooglesitemaps.config import ping_googlesitemap
+from quintagroup.plonegooglesitemaps.config import SUPPORT_BLAYER 
 from quintagroup.plonegooglesitemaps.browser import mobilesitemapview
+from quintagroup.plonegooglesitemaps.interfaces import IGoogleSitemapsLayer
 
 quintagroup.plonegooglesitemaps.config.testing = 1
@@ -70,4 +73,5 @@
         self.workflow = self.portal.portal_workflow
         self.orig_mobile_ifaces = None
+        alsoProvides(self.portal.REQUEST, IGoogleSitemapsLayer)
 
     def patchMobile(self):
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testInstallation.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testInstallation.py	(revision 2750)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testInstallation.py	(revision 2841)
@@ -103,4 +103,12 @@
         self.assertEqual(brain.gsm_stock, gsm_stock)
 
+    def test_browser_layer(self):
+        if not SUPPORT_BLAYER:
+            return
+
+        from plone.browserlayer import utils
+        self.assert_(IGoogleSitemapsLayer in utils.registered_layers(),
+                     "Not registered 'IGoogleSitemapsLayer' browser layer")
+
 
 class TestGoogleSitemapsUninstallation(TestCase):
@@ -125,4 +133,12 @@
             'Configlet found after uninstallation')
 
+    def test_browserlayer_uninstall(self):
+        if not SUPPORT_BLAYER:
+            return
+
+        from plone.browserlayer import utils
+        self.assertEqual(IGoogleSitemapsLayer in utils.registered_layers(), False,
+            "Still registered 'IGoogleSitemapsLayer' browser layer")
+
 
 def test_suite():
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testNewsSitemaps.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testNewsSitemaps.py	(revision 2750)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testNewsSitemaps.py	(revision 2841)
@@ -259,5 +259,7 @@
                             sitemapType="news")
         context = self.portal['news-sitemaps']
-        self.nsmv = queryMultiAdapter((context, TestRequest()), name="news-sitemap.xml")
+        request = TestRequest()
+        alsoProvides(request, IGoogleSitemapsLayer)
+        self.nsmv = queryMultiAdapter((context, request), name="news-sitemap.xml")
 
         self.brain = self.portal.portal_catalog(portal_type="Document")[0]
Index: quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testUpgrade.py
===================================================================
--- quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testUpgrade.py	(revision 2750)
+++ quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/tests/testUpgrade.py	(revision 2841)
@@ -3,6 +3,8 @@
 #
 
+import logging 
 from base import *
 from zope.component import getSiteManager
+from StringIO import StringIO
 
 from Products.CMFPlone.utils import _createObjectByType
@@ -11,4 +13,5 @@
 from quintagroup.plonegooglesitemaps import config
 from quintagroup.plonegooglesitemaps import upgrades as gsm_upgrades
+from quintagroup.plonegooglesitemaps import setuphandlers as sh
 from quintagroup.canonicalpath.interfaces import ICanonicalPath
 from quintagroup.canonicalpath.interfaces import ICanonicalLink
@@ -104,4 +107,79 @@
             self.setup.setLastVersionForProfile(self.profile, orig_ver)
 
+try:
+    from Products.qPloneGoogleSitemaps.content.sitemap import Sitemap as OldSitemap
+except ImportError:
+    PRESENT_OLD_PRODUCT = False
+else:
+    PRESENT_OLD_PRODUCT = True
+    
+class TestMigrationFromProduct(TestCase):
+
+    def afterSetUp(self):
+        super(TestMigrationFromProduct, self).afterSetUp()
+        self.patch_logger()
+        self.gs = self.portal.portal_setup
+        self.profile = u'profile-quintagroup.plonegooglesitemaps:migrate_qPGSM'
+        self.step = "migrate_qPGSM"
+
+    def patch_logger(self):
+        logger = logging.Logger("test:GSM", logging.NOTSET)
+        self.log = StringIO()
+        self.thndlr = logging.StreamHandler(self.log)
+        self.thndlr.setLevel(logging.DEBUG)
+        self.thndlr.setFormatter(logging.Formatter("%(message)s"))
+        logger.addHandler(self.thndlr)
+
+        self.orig_logger = sh.logger
+        sh.logger = logger
+
+    def beforeTearDown(self):
+        sh.logger = self.orig_logger
+
+    def chkLog(self, chkstr):
+        self.thndlr.flush()
+        self.log.seek(0)
+        logs = self.log.getvalue().split('\n')
+        return chkstr in logs
+
+    def testRemoveOldConfiglet(self):
+        chk_str = "Unregistered 'qPloneGoogleSitemaps' "\
+                  "configlet from portal_controlpanel tool."
+        # 1. No qPloneGoogleSitemaps configlet
+        self.gs.runImportStepFromProfile(self.profile, self.step)
+        self.assert_(not self.chkLog(chk_str), self.log.getvalue())
+        # 2. qPloneGoogleSitemaps configlet in portal
+        self.portal.portal_controlpanel.registerConfiglet(
+            id="qPloneGoogleSitemaps", name="qPloneGoogleSitemaps",
+            action="string:")
+        self.gs.runImportStepFromProfile(self.profile, self.step)
+        self.assert_(self.chkLog(chk_str), self.log.getvalue())
+
+    def testRemoveOldSkinLayer(self):
+        chk_str = "Removed 'qPloneGoogleSitemaps' from 'Plone Default' skin."
+        # 1. No qPloneGoogleSitemaps layer in portal_skins
+        self.gs.runImportStepFromProfile(self.profile, self.step)
+        self.assert_(not self.chkLog(chk_str), self.log.getvalue())
+        # 2. qPloneGoogleSitemaps layer in portal_skins
+        skins = self.portal.portal_skins
+        skinpath = 'qPloneGoogleSitemaps,' + skins.getSkinPath("Plone Default")
+        skins._getSelections()["Plone Default"] = skinpath
+        self.gs.runImportStepFromProfile(self.profile, self.step)
+        self.assert_(self.chkLog(chk_str), self.log.getvalue())
+
+    def testRecriateOldSitemaps(self):
+        chk_str = "Successfully replaced '/%s/sitemap.xml' Sitemap" \
+                  % self.portal.id
+        # 1. No old sitemap present in portal
+        self.gs.runImportStepFromProfile(self.profile, self.step)
+        self.assert_(not self.chkLog(chk_str), self.log.getvalue())
+        # 2. Add old sitemap object in to portal
+        self.portal.invokeFactory("Sitemap", 'sitemap.xml')
+        self.assert_('sitemap.xml' in self.portal.objectIds(), self.portal.objectIds())
+        sm = self.portal['sitemap.xml']
+        sm.__class__ = OldSitemap
+        self.gs.runImportStepFromProfile(self.profile, self.step)
+        self.assert_(self.chkLog(chk_str), self.log.getvalue())
+        
 
 def test_suite():
@@ -109,4 +187,7 @@
     suite = TestSuite()
     suite.addTest(makeSuite(TestUpgrade))
+    if PRESENT_OLD_PRODUCT:
+        suite.addTest(makeSuite(TestMigrationFromProduct))
+
     return suite
 
