Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cse493x-24sp/cse493x-24sp-tests
  • wongyh/cse493x-24sp-tests
2 results
Show changes
Commits on Source (14)
openmoji/1F600.png

1.76 KiB

......@@ -21,7 +21,7 @@ CHAPTER_DEADLINES = {
"chapter2": datetime.datetime(2024, 4, 8, tzinfo=PDT),
"chapter3": datetime.datetime(2024, 4, 15, tzinfo=PDT),
"chapter4": datetime.datetime(2024, 4, 22, tzinfo=PDT),
"chapter5": datetime.datetime(2024, 4, 20, tzinfo=PDT),
"chapter5": datetime.datetime(2024, 4, 29, tzinfo=PDT),
"chapter6": datetime.datetime(2024, 5, 6, tzinfo=PDT),
"chapter7": datetime.datetime(2024, 5, 13, tzinfo=PDT),
"chapter8": datetime.datetime(2024, 5, 20, tzinfo=PDT),
......@@ -93,6 +93,7 @@ CURRENT_TESTS = {
"chapter8-exercise-check-boxes-tests.md",
"chapter8-exercise-get-forms-tests.md",
"chapter8-exercise-rich-buttons-tests.md",
"chapter8-exercise-tab-tests.md",
],
"chapter9": ["chapter9-base-tests.md",
"chapter9-exercise-create-element-tests.md",
......
......@@ -38,7 +38,6 @@ Resize the window and set up the URL and web page:
>>> wbemocks.socket.respond_200(url, content)
>>> browser.set_parameters(WIDTH=800, HEIGHT=100,
... VSTEP=20, HSTEP=800, SCROLL_STEP=25)
>>> wbemocks.MockCanvas.hide_above(-20)
Since the h-step is equal to the width and the page contents is 10
letters, there should be 10 lines of text. Since each line is 20
......
......@@ -21,6 +21,27 @@ Make sure you have the expected default values for `HSTEP`, `VSTEP`,
>>> browser.HEIGHT
600
Notes
=====
You might need to modify the `__repr__` method on `Text` and `Tag`
if you factored your project into multiple files: (This is especially
true if you see a mismatched output of the form `<layout.Tag object at ...>`)
```
class Text:
...
def __repr__(self):
return "Text('{}')".format(self.text)
class Tag:
...
def __repr__(self):
return "Tag('{}')".format(self.tag)
```
Testing `lex`
-------------
......
......@@ -81,7 +81,7 @@ You should be able to mix centered and normal text on different lines
Ensure that the application correctly handles the transition from centered to regular text within the same sequence
>>> test_layout('<h1 class="title">center this</h1>then this is regular')
>>> test_layout('<h1 class="title">center this</h1>then this is regular') #doctest: +NORMALIZE_WHITESPACE
[(312.0, 21.0, 'center', Font size=16 weight=normal slant=roman style=None),
(424.0, 21.0, 'this', Font size=16 weight=normal slant=roman style=None),
(13.0, 41.0, 'then', Font size=16 weight=normal slant=roman style=None),
......
......@@ -16,8 +16,7 @@ Testing boilerplate:
>>> _ = wbemocks.ssl.patch().start()
>>> _ = wbemocks.patch_canvas()
>>> import browser
>>> browser.WIDTH
800
>>> browser.set_parameters(WIDTH=800)
>>> def test_layout(text):
... dl = browser.Layout(browser.lex(text)).display_list
... return wbemocks.normalize_display_list(dl)
......
......@@ -43,7 +43,7 @@ If the word fits without splitting then no literal hyphens are present.
When a soft hyphen is replaced with a literal hyphen you need to check that the
text with the hyphen fits on the line.
>>> browser.WIDTH = 90
>>> browser.set_parameters(WIDTH=90)
>>> test_layout("a\N{soft hyphen}b\N{soft hyphen}c\N{soft hyphen}d\N{soft hyphen}e") #doctest: +NORMALIZE_WHITESPACE
[(13.0, 21.0, 'abc-', Font size=16 weight=normal slant=roman style=None),
(13.0, 41.0, 'de', Font size=16 weight=normal slant=roman style=None)]
......@@ -51,7 +51,7 @@ When a soft hyphen is replaced with a literal hyphen you need to check that the
Sometimes a word may be so long that it needs to be split multiple times.
>>> browser.WIDTH = 122
>>> browser.set_parameters(WIDTH=122)
>>> test_layout("multi\N{soft hyphen}word\N{soft hyphen}split") #doctest: +NORMALIZE_WHITESPACE
[(13.0, 21.0, 'multi-', Font size=16 weight=normal slant=roman style=None),
(13.0, 41.0, 'word-', Font size=16 weight=normal slant=roman style=None),
......
......@@ -13,7 +13,7 @@ interaction.
Note that we aren't mocking `dukpy`. It should just run JavaScript normally!
Testing basic <script> support
Testing basic \<script> support
==============================
The browser should download JavaScript code mentioned in a `<script>` tag:
......
......@@ -87,7 +87,7 @@ Replace the id with something that has a different id.
Traceback (most recent call last):
...
_dukpy.JSRuntimeError: ReferenceError: identifier 'one' undefined
at [anon] (duk_js_var.c:1239) internal
...
at eval (eval:1) preventsyield
>>> js.run("replacement;")
{'handle': 2}
......@@ -110,19 +110,19 @@ Empty the document of ids.
Traceback (most recent call last):
...
_dukpy.JSRuntimeError: ReferenceError: identifier 'alice' undefined
at [anon] (duk_js_var.c:1239) internal
...
at eval (eval:1) preventsyield
>>> js.run("one;")
Traceback (most recent call last):
...
_dukpy.JSRuntimeError: ReferenceError: identifier 'one' undefined
at [anon] (duk_js_var.c:1239) internal
...
at eval (eval:1) preventsyield
>>> js.run("replacement;")
Traceback (most recent call last):
...
_dukpy.JSRuntimeError: ReferenceError: identifier 'replacement' undefined
at [anon] (duk_js_var.c:1239) internal
...
at eval (eval:1) preventsyield
>>> browser.print_tree(this_browser.active_tab.document)
DocumentLayout()
......
......@@ -146,10 +146,10 @@ class socket:
cls.URLs[url] = [method, response, body]
@classmethod
def respond_200(cls, url, body, **kwargs):
def respond_200(cls, url, response_body, **kwargs):
response = ("HTTP/1.0 200 OK\r\n" +
"\r\n" +
body).encode()
response_body).encode()
cls.respond(url, response, **kwargs)
@classmethod
......@@ -437,9 +437,8 @@ class MockCanvas:
cmd = "create_text: x={} y={} text={}".format(x, y, text)
self._draw(cmd)
if font is None:
y2 = y
else:
y2 = y + font.metrics("linespace")
font = MockFont(size=20)
y2 = y + font.metrics("linespace")
if self._allow("create_text", y2): print(cmd)
def pack(self, expand=None, fill=None):
......