/usr/lib/python3/dist-packages/notes_app/tests/test_images.py is in notes-app-autopilot 1.4+14.10.20140711-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
# Copyright 2013 Canonical
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
"""Tests for Notes app"""
from __future__ import absolute_import
from testtools.matchers import Equals
from autopilot.matchers import Eventually
from notes_app.tests import NotesTestCaseBaseWithHTTPServer
import sqlite3
class BaseForTestImages(NotesTestCaseBaseWithHTTPServer):
def setUp(self):
self.start_server()
self.setup_db(self.IMAGE)
super(BaseForTestImages, self).setUp()
def setup_db(self, image):
note_data = '{"elements": [{"content":"%s/%s","type":"image"}]}' % \
(self.base_url, image)
path = self.ensure_db()
conn = sqlite3.connect(path)
cursor = conn.cursor()
cursor.execute("DELETE FROM notes")
cursor.execute("INSERT INTO notes (date, note) "
"VALUES ('2013-04-07', '" + note_data + "')")
conn.commit()
conn.close()
def verify_loader_item(self, loader, obj_type):
self.assertThat(loader.progress, Eventually(Equals(1)))
children = loader.get_children_by_type(obj_type)
self.assertThat(len(children), Equals(1))
return children[0]
class MixinForTestImage(object):
def test_no_crash(self):
note = self.main_window.get_notes()[0]
# Expand the note
self.pointing_device.click_object(note)
note.height.wait_for(note.actualExpandedHeight)
# Verify that the note we inserted has the right parts
parts = self.main_window.get_note_parts(note)
self.assertThat(len(parts), Equals(1))
self.verify_loader_item(parts[0], "ImageDelegate")
class TestImageLargeWide(BaseForTestImages, MixinForTestImage):
IMAGE = "large_wide.png"
class TestImageSmallWide(BaseForTestImages, MixinForTestImage):
IMAGE = "small_wide.png"
class TestImageLargeHigh(BaseForTestImages, MixinForTestImage):
IMAGE = "large_high.png"
class TestImageSmallHigh(BaseForTestImages, MixinForTestImage):
IMAGE = "small_high.png"
|